I am using this cell formula to round a given number to 4 sig figs.
=ROUND(Value,4-1-INT(LOG10(ABS(Value))))
I have seen similar VBA code to round to a given number of sig figs (below)
Does anyone know a way to modify this such that excel will round to a given number of sig figs using the rounding rule of evens? Or better yet, a cell formula that will round to a given number of sig figs using the rule of evens?
Function ROUNDSIG(num As Variant, sigs As Variant)
Dim exponent As Double
If IsNumeric(num) And IsNumeric(sigs) Then
If sigs < 1 Then
' Return the " #NUM " error
ROUNDSIG = CVErr(xlErrNum)
Else
exponent = Int(Log(Abs(num)) / Log(10#))
ROUNDSIG = WorksheetFunction.Round(num, _
sigs - (1 + exponent))
End If
Else
' Return the " #N/A " error
ROUNDSIG = CVErr(xlErrNA)
End If
End Function
Bookmarks