In the following dataset there are several amounts that you want to convert to words.
Method 1 – Creating a User-Defined Function Using VBA
Step 1: Create a Function in a VBA Module
- Go to the Developer tab > Code > Visual Basic.
You can also press Alt+F11 to launch the VBA window.
The Microsoft Visual Basic for Applications window will open. - In the VBA window, go to Insert tab > Module.
- Enter the VBA code below in the module window:
Function SpellNumber(ByVal GivenCurrency) Dim USD, C Words = Array("", "", " Thousand ", " Million ", " Billion ", " Trillion ") GivenCurrency = Trim(Str(GivenCurrency)) FractionCurrency = InStr(GivenCurrency, ".") If FractionCurrency > 0 Then C = TensPlace(Left(Mid(GivenCurrency, FractionCurrency + 1) & "00", 2)) GivenCurrency = Trim(Left(GivenCurrency, FractionCurrency - 1)) End If GetIndex = 1 Do While GivenCurrency <> "" GetHundred = "" GetValue = Right(GivenCurrency, 3) If Val(GetValue) <> 0 Then GetValue = Right("000" & GetValue, 3) If Mid(GetValue, 1, 1) <> "0" Then GetHundred = OnesPlace(Mid(GetValue, 1, 1)) & " Hundred " End If If Mid(GetValue, 2, 1) <> "0" Then GetHundred = GetHundred & TensPlace(Mid(GetValue, 2)) Else GetHundred = GetHundred & OnesPlace(Mid(GetValue, 3)) End If End If If GetHundred <> "" Then USD = GetHundred & Words(GetIndex) & USD End If If Len(GivenCurrency) > 3 Then GivenCurrency = Left(GivenCurrency, Len(GivenCurrency) - 3) Else GivenCurrency = "" End If GetIndex = GetIndex + 1 Loop Select Case USD Case "" USD = "No USD" Case "One" USD = "One Dollar" Case Else USD = USD & " USD" End Select Select Case C Case "" C = " and No C" Case "One" C = " and One Cent" Case Else C = " and " & C & " C" End Select SpellNumber = USD & C End Function Function TensPlace(TensDigit) Dim Output As String Output = "" If Val(Left(TensDigit, 1)) = 1 Then Select Case Val(TensDigit) Case 10: Output = "Ten" Case 11: Output = "Eleven" Case 12: Output = "Twelve" Case 13: Output = "Thirteen" Case 14: Output = "Fourteen" Case 15: Output = "Fifteen" Case 16: Output = "Sixteen" Case 17: Output = "Seventeen" Case 18: Output = "Eighteen" Case 19: Output = "Nineteen" Case Else End Select Else Select Case Val(Left(TensDigit, 1)) Case 2: Output = "Twenty " Case 3: Output = "Thirty " Case 4: Output = "Forty " Case 5: Output = "Fifty " Case 6: Output = "Sixty " Case 7: Output = "Seventy " Case 8: Output = "Eighty " Case 9: Output = "Ninety " Case Else End Select Output = Output & OnesPlace(Right(TensDigit, 1)) End If TensPlace = Output End Function Function OnesPlace(OnesDigit) Select Case Val(OnesDigit) Case 1: OnesPlace = "One" Case 2: OnesPlace = "Two" Case 3: OnesPlace = "Three" Case 4: OnesPlace = "Four" Case 5: OnesPlace = "Five" Case 6: OnesPlace = "Six" Case 7: OnesPlace = "Seven" Case 8: OnesPlace = "Eight" Case 9: OnesPlace = "Nine" Case Else: OnesPlace = "" End Select End Function
- Click Save.
- In Save As, select Excel Macro-Enabled Workbook in Save as type > Save.
A new function: SpellNumber was created.
Step 2: Apply the User Defined Function
- Go back to the workbook and select a blank cell.
- In B5, enter the formula:
=SpellNumber(B5)
. - Press Enter.
The currency will be converted to words.
- Drag down the Fill Handle.
All currency amounts will be converted into words.
Method 2 – Applying an Excel Formula
Only the integers are correctly converted. Decimal conversion can result in errors.
- In B5, enter the formula:
=IF(OR(LEN(FLOOR(B5,1))=13,FLOOR(B5,1)<=0),"Out of range",PROPER(SUBSTITUTE(CONCATENATE(CHOOSE(MID(TEXT(INT(B5),REPT(0,12)),1,1)+1,"","one hundred ","two hundred ","three hundred ","four hundred ","five hundred ","six hundred ","seven hundred ","eight hundred ","nine hundred "),CHOOSE(MID(TEXT(INT(B5),REPT(0,12)),2,1)+1,"",CHOOSE(MID(TEXT(INT(B5),REPT(0,12)),3,1)+1,"ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"),"twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"),IF(VALUE(MID(TEXT(INT(B5),REPT(0,12)),2,1))>1,CHOOSE(MID(TEXT(INT(B5),REPT(0,12)),3,1)+1,"","-one","-two","-three","-four","-five","-six","-seven","-eight","-nine"),IF(VALUE(MID(TEXT(INT(B5),REPT(0,12)),2,1))=0,CHOOSE(MID(TEXT(INT(B5),REPT(0,12)),3,1)+1,"","one","two","three","four","five","six","seven","eight","nine"),"")),IF(B5>=10^9," billion ",""),CHOOSE(MID(TEXT(INT(B5),REPT(0,12)),4,1)+1,"","one hundred ","two hundred ","three hundred ","four hundred ","five hundred ","six hundred ","seven hundred ","eight hundred ","nine hundred "),CHOOSE(MID(TEXT(INT(B5),REPT(0,12)),5,1)+1,"",CHOOSE(MID(TEXT(INT(B5),REPT(0,12)),6,1)+1,"ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"),"twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"),IF(VALUE(MID(TEXT(INT(B5),REPT(0,12)),5,1))>1,CHOOSE(MID(TEXT(INT(B5),REPT(0,12)),6,1)+1,"","-one","-two","-three","-four","-five","-six","-seven","-eight","-nine"),IF(VALUE(MID(TEXT(INT(B5),REPT(0,12)),5,1))=0,CHOOSE(MID(TEXT(INT(B5),REPT(0,12)),6,1)+1,"","one","two","three","four","five","six","seven","eight","nine"),"")),IF(VALUE(MID(TEXT(INT(B5),REPT(0,12)),4,3))>0," million ",""),CHOOSE(MID(TEXT(INT(B5),REPT(0,12)),7,1)+1,"","one hundred ","two hundred ","three hundred ","four hundred ","five hundred ","six hundred ","seven hundred ","eight hundred ","nine hundred "),CHOOSE(MID(TEXT(INT(B5),REPT(0,12)),8,1)+1,"",CHOOSE(MID(TEXT(INT(B5),REPT(0,12)),9,1)+1,"ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"),"twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"),IF(VALUE(MID(TEXT(INT(B5),REPT(0,12)),8,1))>1,CHOOSE(MID(TEXT(INT(B5),REPT(0,12)),9,1)+1,"","-one","-two","-three","-four","-five","-six","-seven","-eight","-nine"),IF(VALUE(MID(TEXT(INT(B5),REPT(0,12)),8,1))=0,CHOOSE(MID(TEXT(INT(B5),REPT(0,12)),9,1)+1,"","one","two","three","four","five","six","seven","eight","nine"),"")),IF(VALUE(MID(TEXT(INT(B5),REPT(0,12)),7,3))," thousand ",""),CHOOSE(MID(TEXT(INT(B5),REPT(0,12)),10,1)+1,"","one hundred ","two hundred ","three hundred ","four hundred ","five hundred ","six hundred ","seven hundred ","eight hundred ","nine hundred "),CHOOSE(MID(TEXT(INT(B5),REPT(0,12)),11,1)+1,"",CHOOSE(MID(TEXT(INT(B5),REPT(0,12)),12,1)+1,"ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"),"twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"),IF(VALUE(MID(TEXT(INT(B5),REPT(0,12)),11,1))>1,CHOOSE(MID(TEXT(INT(B5),REPT(0,12)),12,1)+1,"","-one","-two","-three","-four","-five","-six","-seven","-eight","-nine"),IF(VALUE(MID(TEXT(INT(B5),REPT(0,12)),11,1))=0,CHOOSE(MID(TEXT(INT(B5),REPT(0,12)),12,1)+1,"","one","two","three","four","five","six","seven","eight","nine"),"")))," "," ")&IF(FLOOR(B5,1)>1,"",""))&IF(ISERROR(FIND(".",B5,1)),""," "&PROPER(IF(LEN(LEFT(TRIM(MID(SUBSTITUTE(Sheet1!B5,".",REPT(" ",255)),255,200)),2))=1,CHOOSE(1*LEFT(TRIM(MID(SUBSTITUTE(Sheet1!B5,".",REPT(" ",255)),255,200)),2),"ten","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety")&"","")&CONCATENATE(CHOOSE(MID(TEXT(INT(LEFT(TRIM(MID(SUBSTITUTE(Sheet1!B5,".",REPT(" ",255)),255,200)),2)),REPT(0,12)),11,1)+1,"",CHOOSE(MID(TEXT(INT(LEFT(TRIM(MID(SUBSTITUTE(Sheet1!B5,".",REPT(" ",255)),255,200)),2)),REPT(0,12)),12,1)+1,"ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen")&"","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"),IF(VALUE(MID(TEXT(INT(LEFT(TRIM(MID(SUBSTITUTE(Sheet1!B5,".",REPT(" ",255)),255,200)),2)),REPT(0,12)),11,1))>1,CHOOSE(MID(TEXT(INT(LEFT(TRIM(MID(SUBSTITUTE(Sheet1!B5,".",REPT(" ",255)),255,200)),2)),REPT(0,12)),12,1)+1,"","-one","-two","-three","-four","-five","-six","-seven","-eight","-nine")&"",IF(LEFT(TRIM(MID(SUBSTITUTE(Sheet1!B5,".",REPT(" ",255)),255,200)),2)="01","one cent",IF(LEFT(TRIM(MID(SUBSTITUTE(Sheet1!B5,".",REPT(" ",255)),255,200)),1)="0",CHOOSE(MID(TEXT(INT(LEFT(TRIM(MID(SUBSTITUTE(Sheet1!B5,".",REPT(" ",255)),255,200)),2)),REPT(0,12)),12,1)+1,"","one","two","three","four","five","six","seven","eight","nine")&"","")))))))
- Press Enter. Integer numbers were converted to words.
- Drag down the Fill Handle.
All amounts will be converted to words.
Download Practice Workbook
Download the practice workbook.
Frequently Asked Questions
Can I customize the VBA code to meet specific styling requirements?
The VBA code can be customized to suit specific styling requirements or additional formatting needs.
Can I use this method for different currencies and locales?
Yes, you will have to modify the VBA code or localization settings.
<< Go Back to Currency Format | Number Format | Learn Excel
Get FREE Advanced Excel Exercises with Solutions!
extremely useful!
Hi Bernadeth,
Thanks for your appreciation. To get more useful content kindly visit our site.
Thanks
Regards
ExcelDemy