MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Writing "Anything but a number"


Posted by Christopher on September 26, 2001 10:02 AM

I want a line in my VB to say if cell(x,2) = "anthing other than a number" goto...

How do I write in code "anything other a number?
or not a number. Same thing.

Thanks


Posted by Barrie Davidson on September 26, 2001 10:17 AM

Try,

If IsNumeric(Cells(x, 2).Value) = True Then Go To

Regards,
Barrie

Barrie Davidson

Posted by Phil Hamlett on September 26, 2001 10:19 AM

Have you tried
If Not IsNumeric(Worksheets("Name").cells([row],[col]).Value) Then
?
Phil

Posted by Christopher on September 26, 2001 10:24 AM

Tried that. I couldn't get it to work.

It wants an end of statement after the True

Posted by Barrie Davidson on September 26, 2001 11:06 AM

Re: Tried that. I couldn't get it to work.

Sorry, I assumed you would know the entire syntax (I know, I know...."you know what happens when you assume"!). Try this

If IsNumeric(Cells(x, 2).Value) = False Then Go To 'insert location here
End If

I also changed the IF statement from TRUE to FALSE, since you wanted the GO TO statement used if the value was not numeric (I reversed the direction you wanted).

Hope this helps you out.

Barrie

Barrie Davidson

Posted by Christopher on September 26, 2001 11:24 AM

I appreciate your help, But here is how I did it.

The rest of the thing wasn't the problem, For somereason I would type in what you agave me but it expected a then instead of the true or something. Anyway I didin't spend that mutch time on it.

Here's the code that I did use.
If Not Cells(x,3).Numberformat = "0" then Goto etc...

Thanks for your time.