Public Function FormatSigFig(Value As Double, SigFigs As Long) As String
Dim RoundedValue As Double
Dim Digits As Long
Digits = SigFigs - Int(Log(Abs(Value)) / Log(10)) - 1
FormatSigFig = Int(0.5 + Value * 10 ^ Digits) / 10 ^ Digits
End Function
Can you explain in more detail exactly what you are trying to do?
I'm not sure it's that simple. 0 is insignificant if it's at the beginning, but not if in between significant figures (all others), and is if it is after a decimal. Maybe what you had in mind would be ok, though.If your values always had the same number of digits to the left of the decimal point (i.e. "2"), then you might be able to accomplish what you want with the FORMAT function. Otherwise, you would probably need to use some VBA code, like you have (or some other code).