Avatar of Fordraiders
Fordraiders
Flag for United States of America

asked on 

evaluate a negative number

excel 2010 vba

The data is being grabbed off a worksheet

Trying to catch a negative number and do stuff with it..

Dim CellDataEvaluate As String
' for example
CellDataEvaluate =  -0.82
 


' catch a negative number
 If IsNumeric(CellDataEvaluate) And InStr(1, CellDataEvaluate, ".") And InStr(1, CellDataEvaluate, "-") < 0 Then   ' this should catch a negative string
                             CellDataEvaluate = CDec(CellDataEvaluate)

The line above is not catching a negative number ?


Thanks
fordraiders
VBAMicrosoft ExcelMicrosoft Office

Avatar of undefined
Last Comment
Chris Raisin

8/22/2022 - Mon