Is there a way to spell out numbers in Excel? In other words, I have numbers 1-50 listed in column A. I want to spell out "one" to "fifty" in column B.
It needs to be added to a module within the workbook or your personal.xls file (i it exists)
'Here is what I use, it works for up to Sextllions. It will also give you something like
'Three Hundred Thirty Dollars and Sixty Seven Cents if you pass it the optional second and third parameters. like this:
Public Function NumberToText(Num As Variant, Optional vCurName As Variant, Optional vCent As Variant) As Variant
Dim TMBT As Variant
Dim sNum As String, sDec As String, sHun As String, IC As Integer
Dim Result As String, sCurName As String, sCent As String
If Application.IsNumber(Num) = False Then
NumberToText = CVErr(xlValue)
Exit Function
End If
If IsMissing(vCurName) Then
sCurName = ""
Else
sCurName = Trim(CStr(vCurName))
End If
If IsMissing(vCent) Then
sCent = ""
Else
sCent = Trim(CStr(vCent))
End If
If IsMissing(sCent) Or IsNull(sCent) Then
sNum = Format(Application.Round(Num, 0), "0"
Else
sNum = Format(Application.Round(Num, 2), "0.00"
sDec = Right(sNum, 2)
sNum = Left(sNum, Len(sNum) - 3)
If CInt(sDec) <> 0 Then
sDec = "and " & Trim(HundredsToText(CVar(sDec)) & " " & sCent)
Else
sDec = ""
End If
End If
IC = 0
While Len(sNum) > 0
sHun = Right(sNum, 3)
sNum = Left(sNum, Application.Max(Len(sNum) - 3, 0))
If CInt(sHun) <> 0 Then
Result = Trim(Trim(HundredsToText(CVar(sHun)) & " " & TMBT(IC)) & " " & Result)
End If
IC = IC + 1
Wend
Result = Trim(Result & " " & sCurName)
Result = Trim(Result & " " & sDec)
NumberToText = Result
End Function
Private Function HundredsToText(Num As Integer) As String
Dim Units As Variant, Teens As Variant, Tens As Variant
Dim i As Integer, IUnit As Integer, ITen As Integer, IHundred As Integer
Dim Result As String
Result = ""
IUnit = Num Mod 10
i = Int(Num / 10)
ITen = i Mod 10
IHundred = Int(i / 10)
If IHundred > 0 Then
Result = Units(IHundred) & " Hundred"
End If
If ITen = 1 Then
Result = Result & " " & Teens(IUnit)
Else
If ITen > 1 Then
Result = Trim(Result & " " & Tens(ITen) & " " & Units(IUnit))
Else
Result = Trim(Result & " " & Units(IUnit))
End If
End If
It is downloaded in a zip file which also contains an informative file in 'hlp' format that describes the 33 or so very useful functions included, one of which does the number to words conversion you describe (supports various
languages and currencies).
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.