Isnumeric() returning incorrect result

G

Guest

Using XL 2003 & 97

The following code (Below ********) is just part of a Sub Routine.

For some reason IsNumeric() is returning a "True" even though the statement
should be false. (I could be wrong or do not understand IsNumeric() function)

What I mean is this:
The myFormulaStr is ="=(C47+C48+C49)"
PositionInmyFormula = 6 (Correctly, "+" is found in the sixth (6) position)
The 6th position + 1 should be the letter "C" ... therefore not numeric.

I would then expect the IsNumeric() to return false ... no?

Also, (in a copy of the following subroutine) I also test for a numeric
after the "=" sign. IsNumeric again returns a "True" even though the formula
is: =SUM(C16+C26+C35+C41+C44+C51)

In this case the value of PositionInmyFormula = 1 therefore,
PositionInmyFormula = 1 + 1 should be "S" ??

In the two (2) stuations above, why is IsNumeric() returning a "True" when a
False should be the result?

Thanks in Advance

Dennis

********** Sub Routine **********************************

Dim myCell, myRange As Range
Dim myFormulaStr As String
Dim PositionInmyFormula As Integer

myFormulaStr = myCell.Formula ' Formula is
=(C47+C48+C49)
PositionInmyFormula = InStr(myFormulaStr, "+") ' PositionInFormula is 6
If PositionInmyFormula > 0 Then
If Worksheet.Function.isumeric(Mid(myFormulaStr, _
PositionInmyFormula + 1, 1)) Then
myCell.Interior.ColorIndex = 8
End If
End If
 
G

Guest

I found the problem! Da!

I was using Worksheet.Function.IsNumeric

The XL function is IsNumber() or (in VBA) Worksheet.Function.IsNumber

The VBA function is IsNumeric()

Dennis
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top