VBA,Excel

ExcelVBA 有効数字を返す関数

More than 1 year has passed since last update.

メモがてら。
worksheetfunctionだけで対応可能。

=======================================
Function ConvertSFig(ByVal a As Variant, ByVal n As Integer) As Double
Dim b As Double
b = WorksheetFunction.Round(a, n - 1 - Int(WorksheetFunction.Log10(CDbl(a))))
ConvertSFig = b
End Function
=======================================