Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Rob,
First my formula suggestion: =--TEXT(A1,"0."&REPT("0",A2-1)&"E+000") In A1 you have your original number, in A2 the count of significant digits you want. My UDF: Function dbl2nsig(d As Double, _ Optional n As Long = 3) _ As String 'Returns string presentation of d with 'n significant digits. PB V0.01 Dim i As Long, j As Long Dim s As String, sr As String s = Format(d, "0." & String(n - 1, "0") _ & "E+000") i = Right(s, 4) Select Case i Case Is n - 2 sr = Left(s, 1) If n 1 Then sr = sr & Mid(s, 3, n - 1) sr = sr & String(i - n + 1, "0") Case 0 sr = Left(s, n + 1) Case Is < 0 sr = "0." & String(-1 - i, "0") & Left(s, 1) _ & Mid(s, 3, n - 1) Case Else s = Left(s, 1) & Mid(s, 3, n - 1) sr = Left(s, i + 1) & "." & _ Right(s, n - i - 1) End Select dbl2nsig = sr End Function HTH, Bernd |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
significant figures | Excel Worksheet Functions | |||
significant figures? | Excel Discussion (Misc queries) | |||
Rounding/Significant figures | Excel Worksheet Functions | |||
more newbie help on my significant figures function... | Excel Programming | |||
pls help newbie with my significant figures function | Excel Programming |