User form - Testing for numbers or text
Jacob, I put in the code below and it still fails for both text and blank. Is
there something that could be wrong in the way I have the text box properties
set up. I have even tried setting default value of box to "blank" and if
rider5.text ="blank" then, just to see if I could work with text and it
failed too. Only seems to want to work with numbers for some reason.
Thanks
"Jacob Skaria" wrote:
You can ignore the previous post and try
If Rider5.Value < 100 Or Trim(Rider5.Text) = "" Or IsNumeric(Rider5.Text) =
False Then
'your code
End If
If this post helps click Yes
---------------
Jacob Skaria
"Jacob Skaria" wrote:
Two options..
If you dont have any code to be executed after the one you pasted below try
If IsNumeric(Rider5.Text) = True Then
If Rider5.Text 99 Then Exit Sub
End If
'The below codes will be executed only if text or value less than 100
UnkRow = Sheets("Unknown").Cells(Rows.Count, "A").End(xlUp).Row + 1
Sheets("Unknown").Range("A" & UnkRow) = Rider5.Text
Sheets("Unknown").Range("B" & UnkRow) = Time5.Text
End Sub
'-------------------------------------------------------------------------
Another approach is to have a boolean to validate and
Dim blnPass As Boolean
If IsNumeric(Rider5.Text) = False Then
blnPass = True
Else
If Rider5.Text < 100 Then blnPass = True
End If
If blnPass = True Then
UnkRow = Sheets("Unknown").Cells(Rows.Count, "A").End(xlUp).Row + 1
Sheets("Unknown").Range("A" & UnkRow) = Rider5.Text
Sheets("Unknown").Range("B" & UnkRow) = Time5.Text
End If
'Continue with the rest of your code
End Sub
If this post helps click Yes
---------------
Jacob Skaria
"NDBC" wrote:
I need the following if statement to be true for times when the the text box
Rider5.Text is numbers less than 100 (done), or any text value, or blank. I
can put in the or statements but don't know what function to use.
'When rider number is less than lowest rider number or Any text value
(entered in error)
If Rider5.Text < 100 Then
UnkRow = Sheets("Unknown").Cells(Rows.Count, "A").End(xlUp).Row + 1
Sheets("Unknown").Range("A" & UnkRow) = Rider5.Text
Sheets("Unknown").Range("B" & UnkRow) = Time5.Text
Thanks
|