A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
B1: =FormatAsExponent(A1)
Function FormatAsExponent(ByVal n As Double, Optional ByVal Places As Long = 2) As String
'Return a nicely formatted text string (for use as UDF in Excel)
Dim Numbers
Numbers = Array(&H2070, &HB9, &HB2, &HB3, &H2074, &H2075, &H2076, &H2077, &H2078, &H2079)
Dim i As Long, e As Long
Dim es As String
'Format N as scientific number
FormatAsExponent = Format(n, "0." & String(Places, "0") & "E+000")
'Get the exponent as value
e = Val(Right(FormatAsExponent, 4))
'Prepare our format
FormatAsExponent = Left(FormatAsExponent, InStr(FormatAsExponent, "E") - 1) & "x10"
If e < 0 Then
'Add the negative sign
FormatAsExponent = FormatAsExponent & ChrW(&H207B)
End If
es = CStr(Abs(e))
'Add the exponent chars
For i = 1 To Len(es)
FormatAsExponent = FormatAsExponent & ChrW(Numbers(CInt(Mid(es, i, 1))))
Next
End Function