View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.misc
NDBC NDBC is offline
external usenet poster
 
Posts: 204
Default User form - Testing for numbers or text

Or IsNumeric(Rider5.Text) = False Then

This statement alone handles blank cells too.



"NDBC" wrote:

My apologies Jacob. I just changed the rider5.text <100 to rider5.value<100
and everything works fine now.

You were on the money yet again

"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