Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 204
Default User form - Testing for numbers or text

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
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,520
Default User form - Testing for numbers or text

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

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,520
Default User form - Testing for numbers or text

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

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 204
Default 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

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 204
Default User form - Testing for numbers or text

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



  #6   Report Post  
Posted to microsoft.public.excel.misc
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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Highlight/Select text in User Form? Alan Smith Excel Discussion (Misc queries) 2 September 13th 07 09:02 PM
Adding a new text box to user form Marilyn Excel Discussion (Misc queries) 3 May 13th 07 11:42 PM
User Form: Cannot Update Text Box Charles in Iraq Excel Discussion (Misc queries) 0 October 12th 06 07:53 AM
user form question: text box to display result BigPig Excel Discussion (Misc queries) 0 February 28th 06 12:33 AM
Use a text box to calculate and show results in a user form stockpick Excel Discussion (Misc queries) 6 August 6th 05 06:04 AM


All times are GMT +1. The time now is 02:42 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"