Run the sub on separate cells that are: blank, have a number, have a date, have text, have true or false.
It can help explain why your question often generates disparate answers about the "best" way to check for "numbers".
'--
Sub ValidNumber()
Dim rng
Set rng = ActiveCell
MsgBox "IsNumber: " & Application.WorksheetFunction.IsNumber(rng) & vbCr & _
"IsNumeric: " & VBA.IsNumeric(rng) & vbCr & _
"TypeName Value: " & VBA.TypeName(rng.Value) & vbCr & _
"TypeName Value2: " & VBA.TypeName(rng.Value2) & vbCr & _
"Val-Value: " & Val(rng.Value) & vbCr & _
"Val-Value2: " & Val(rng.Value2)
End Sub
'--
This function may/might/could do what you want...
Function IsValidNumber2(ByRef rng As Excel.Range) As Boolean
'Jim Cone - September 2010
If Application.WorksheetFunction.IsNumber(rng) = True _
And VBA.IsNumeric(rng) = True Then
IsValidNumber2 = True
End If
End Function
--
Jim Cone
Portland, Oregon USA
http://tinyurl.com/TrialVersions Excel add-ins
..
..
..
"shy1162" <
[email protected]>
wrote in message
Is there a simple way to check if a cell contains a number, not text.
I would like to be able to verify that the cell contains a number
before doing some multiplication/division by a macro. Thanks.
excel 2000