I have written the user-defined function (UDF) below for an Excel sheet at work. It rounds to significant figure and is able to handle trailing zeros.
Actually, the UDF works as intended! The only thing, that you need to be aware off is that it convert the number to text.
However, I'm just a bit suspicious that I've overlooked something. Compared to the others functions, that I have found (Eg. https://www.vertex42.com/ExcelTips/significant-figures.html), it seems almost too simple.
Public Function ROUNDSF(num As Double, sigFig As Integer)
Dim sigPlace As Integer
Dim numFormat As String
sigPlace = sigFig - (1 + Int(Log(num) / Log(10)))
numFormat = "0." & String(sigPlace, "0")
ROUNDSF= Format(num, numFormat)
End Function
Are there anything, that I overlooked in this UDF? Or any suggestions?