IsNumeric

elgringo56

Well-known Member
Joined
Apr 15, 2002
Messages
869
I may be using this wrong. Can someone shed some light on it for me? I have the following in my code:
If IsNumeric("D9") = False Then
Code
End If

The problem is, even when Cell D9 contains a number I am returned a False causing the code to execute, which I dont want.
 
I find that Loops , conditionals etc all get messed up for this reason... so I always trim my cells before testing for anything ! Seems to save me from lots of errors in my code.
 
Upvote 0

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
I dont know if there are chat rooms on this site or not. Its a long question, more of a discussion.
 
Upvote 0
Cell values. I have had similiar problems.
A blank cell returns a data type called "Empty" Different than null. Empty will evaluate to a number with the IsNumeric function.
Another way around this would be the following syntax:

If Not IsNumeric(Sheet1.Range("A1").Text)

By forcing a Cell, which is always a variant, to be evaluated as text, the IsNumeric function will return false if there is not actually a number in the cell.

I don't know if this helps you or not.
The trim statement works fine for the same reason. Causes the cell to be evaluated as a string as well. You could argue that a property assignment uses less resources than inserting another function.
Frankly, I use whatever works and works now.
NWIM?
Tom

Tom
 
Upvote 0

Forum statistics

Threads
1,215,092
Messages
6,123,064
Members
449,090
Latest member
fragment

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top