PDA

View Full Version : If function wont distinguish between letters and numbers.



hugh1994
05-19-2014, 01:01 AM
I need the following If function to not recognise letters or any other characters as values > 0, and if any values that are not numbers > 0 are put in the input box, for the MsgBox to appear, but their is no Dim that exists to do this, so how can I?
Thanks.


Do


Dim Span As String ' not sure what dim to have here (non work for what i want to do)
Span = InputBox("Enter the Length of the Beam", "(mm)")


If (Span > 0) Then
[B4].Value = Span
Exit Do
Else
[A2].Value = nil2
MsgBox ("The beam length you entrered is not valid. Please input a new beam length")
End If


Loop While [A2].Value = nil2

hugh1994
05-19-2014, 01:19 AM
Bump!

Bob Phillips
05-19-2014, 01:23 AM
Do

Dim Span As Double
Span = Application.InputBox("Enter the Length of the Beam", "(mm)", Type:=1)

If Span > 0 Then

[B4].Value = Span
Exit Do
Else

[A2].Value = nil2
MsgBox ("The beam length you entered is not valid. Please input a new beam length")
End If
Loop While [A2].Value = nil2

Bob Phillips
05-19-2014, 01:25 AM
Bump!

18 minutes and you bump it. Bit impatient isn't it?

hugh1994
05-19-2014, 01:37 AM
18 minutes and you bump it. Bit impatient isn't it?
Yes, it has been annoying me for a while. Sorry.

hugh1994
05-19-2014, 01:39 AM
Thank you so much! What you did makes so much more sense than the things I was trying. Your a legend!