Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

Detecting text vs numbers with an If/Then

  Asked By: Phil    Date: Sep 22    Category: MS Office    Views: 958
  

I'm sure this is simple, but I can't seem to find it anywhere.

I'm doing an If/then that performs some < and > comparisons, but
there are some #REF error fields mixed in as well. My script chokes
when it hits the error messages, because I'm trying to perform < and
> comparisons on text.

What do I use in my first If statement that will allow it to skip
fields that don't have numbers?

If Cells(Tallyrow, 13).Value **ISN'T A NUMBER**
End if

ElseIf Cells(Tallyrow, 13).Value > 0 And Cells(Tallyrow, 13).Value <
2 Then
Sheets("Email").Select
Rows(Emailrow).Select
With Selection.Interior
.ColorIndex = 44
.Pattern = xlSolid
End With

ElseIf Cells(Tallyrow, 13).Value > 1.999 And Cells(Tallyrow,
13).Value < 3 Then
Sheets("Email").Select
Rows(Emailrow).Select
With Selection.Interior
.ColorIndex = 36
.Pattern = xlSolid
End With

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Lughaidh Fischer     Answered On: Sep 22

The IsNumeric() function will determine if it is a number. For example:

If IsNumeric(Cells(Tallyrow, 13)) then
End If

Also, take a look at:

http://www.j-walk.com/ss/excel/tips/tip62.htm

 
Didn't find what you were looking for? Find more on Detecting text vs numbers with an If/Then Or get search suggestion and latest updates.




Tagged: