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.
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Try the following: -

If Not IsNumeric(Range("D9").Value) Then
Code
End If

Brought to you courtesy of the Breeders and Cannonball.
 
Upvote 0
Thats because your not refering to a cell your just testing a text string i.e. what ever you put into quotes is text. Here this code will do the job for you.

If Not IsNumeric(Trim(Range("D9").Value)) Then
'place code here
End If
 
Upvote 0
Mudface solution is almost correct other then it will test a blank cell as holding a value of Zero.... which is a number! If you don't want blank cells testing true as a number then use my solution with the added trim function in it.
If Not IsNumeric(Trim(Range("D9").Value)) Then
'place code here
End If
This message was edited by Nimrod on 2002-05-04 18:26
This message was edited by Nimrod on 2002-05-04 18:27
 
Upvote 0
Ok, Nimrods worked, but I will be darned if I know why. I dont understand this one at all. That being said, thanks a lot, you got me going
 
Upvote 0
Without trimming you have an empty string which is evaluated to zero. The trim command means that the empty string is removed therefore eliminating the evaluation to Zero.
 
Upvote 0
Nimrod, can we get in a chat somewhere, you may be giving me the answer to a question that has nagged me for a long time concerning "empty" cells.
 
Upvote 0
Aye, sorry, should've been the code below to check for a blank cell too: -

If Not IsNumeric(Range("D9").Text) Then
Code
End If

All the code is saying is that if the cell d9 contains anything but a number then ...
 
Upvote 0
My email is presently down .. is there any chat rooms on this site ? ... or you could ask the question here ?
 
Upvote 0

Forum statistics

Threads
1,213,536
Messages
6,114,215
Members
448,554
Latest member
Gleisner2

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