I\'m trying to get the log of a number but it looks like the Worksheet function gives one answer, and VBA another.
In VB, using Log(Range(\"A2\"))
where
VBA's Log
function is the natural log. If you want log base ten you will have to use the logarithmic identity for converting bases. Like so: Log(x)/Log(10)
.
Function roundit1(nn As Variant, sd As Variant)
nn = Val(nn)
If Not (nn = 0) Then
xx = (1 + Int(Log(Abs(nn)) / Log(10)))
Else
xx = 0
End If
' significant digits
roundit = sd - xx
If roundit < 0 Then roundit = 0
roundit1 = Round(nn, roundit)
End Function