What I have:
worksheet with negative numbers in cells like -.29 or -0.2900 or -00.29 etc...
I have a variable(CellDataEvaluate) that needs Dim CellDataEvaluate As String
formatting because the value is getting posted to a text file.
However, I'm not properly capturing the negative numbers with my code.
If IsNumeric(CellDataEvaluate) And InStr(1, CellDataEvaluate, ".") < 0 Then
CellDataEvaluate = Format(CellDataEvaluate, "-0.0000")
If IsNumeric(CellDataEvaluate) And InStr(1, CellDataEvaluate, ".") < 0 Then CellDataEvaluate = Format(CellDataEvaluate, "-0.0000") ' number is not negative gp If IsNumeric(CellDataEvaluate) And InStr(1, CellDataEvaluate, ".") > 0 Then CellDataEvaluate = Format(CellDataEvaluate, "0.0000") If IsNumeric(CellDataEvaluate) And CellDataEvaluate > "0.0000" And CellDataEvaluate < "1.000" Then CellDataEvaluate = Format(CellDataEvaluate, "0.0000") '* 100 Else CellDataEvaluate = CellDataEvaluate End If ' inside else if Else End If End If ' evaluates for Negative number End If ' evaluate cells if
Are you having problems saving the numbers to a csv file?
No..
Are the cells actually formatted as numbers and not text?
Formatted as "custom"
To test if a number is negative you simply need to test if the value is less than zero.
What do you mean by "capturing" ???
Also, do not confuse cells format with cells value, these arn't related to each other.