How do I display a number in writing (letters)

  • Thread starter Dr. Dhia A. Mousa Al-Ani
  • Start date
D

Dr. Dhia A. Mousa Al-Ani

Hi, Could you please tell me how can I display a number in writing its value
(letters)
for example if I have a cell contains the result 43529.
How can i display this result in writing like:
Forty Three Thousand Five Hundred Twenty Nine Only

Please help
Best regards

Dr. Dhia Al-Ani
 
J

Jim Thomlinson

That requires vba... Here is a function that will get you close...

Public Function SpellNumber(ByVal MyNumber)
Dim Dollars, Cents, Temp
Dim DecimalPlace, Count
ReDim Place(9) As String
Place(2) = " Thousand "
Place(3) = " Million "
Place(4) = " Billion "
Place(5) = " Trillion "
' String representation of amount.
MyNumber = Trim(str(MyNumber))
' Position of decimal place 0 if none.
DecimalPlace = InStr(MyNumber, ".")
' Convert cents and set MyNumber to dollar amount.
If DecimalPlace > 0 Then
Cents = GetTens(Left(Mid(MyNumber, DecimalPlace + 1) & _
"00", 2))
MyNumber = Trim(Left(MyNumber, DecimalPlace - 1))
End If
Count = 1
Do While MyNumber <> ""
Temp = GetHundreds(Right(MyNumber, 3))
If Temp <> "" Then Dollars = Temp & Place(Count) & Dollars
If Len(MyNumber) > 3 Then
MyNumber = Left(MyNumber, Len(MyNumber) - 3)
Else
MyNumber = ""
End If
Count = Count + 1
Loop
Select Case Dollars
Case ""
Dollars = "No Dollars"
Case "One"
Dollars = "One Dollar"
Case Else
Dollars = Dollars & " Dollars"
End Select
Select Case Cents
Case ""
Cents = " and No Cents"
Case "One"
Cents = " and One Cent"
Case Else
Cents = " and " & Cents & " Cents"
End Select
SpellNumber = Application.Trim(Dollars & Cents)
End Function

Place that code in a standard code module (the same place as the code from a
recorded mcaro ends up). Now in any cell in the worksheet you can use this
like this...

=SpellNumber(A1)
where A1 has the numer you want spelled out...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top