Function SigFigs(number) ' Assumes EXCEL 2000 or later. ' Created by Neil J. Gunther, Wed Jun 5 18:02:29 2002 ' Updated by Neil J. Gunther, Tue Jun 18 10:00:06 2002 Dim numString As String Dim numParts As Variant 'Treat the number as a string literal numString = CStr(number) If (numString Like "*.*") Then 'check for decimal point numParts = Split(numString, ".") 'Separate integer and fractional parts digString = numParts(0) & numParts(1) 'Concatenate sans decimal point nlength = Len(digString) i = 1 'Match FORWARDS from LEFTmost digit... patString = "[1-9]*" 'non-zero digit preceding zero or more digits Do While i < nlength If (digString Like patString) Then Exit Do End If patString = "?" & patString 'prepend any digit metacharacter i = i + 1 Loop SigDigs = nlength - i Else 'no decimal point so, scan number as is ... nlength = Len(numString) i = 0 'Match BACKWARDS from RIGHTmost digit... patString = "*[1-9]" 'zero or more digits preceding a non-zero digit Do While i < nlength If (numString Like patString) Then Exit Do End If patString = patString & "?" 'append any digit metacharacter i = i + 1 Loop SigDigs = nlength - i End If SigFigs = SigDigs 'Return result to spreadsheet cell End Function