Crafting invoices, financial reports, or official documents requires the use of expressing currency to words. This practice makes it easy for anyone to read and understand the numerical data. Thus, helping diverse stakeholders to understand and comprehend any report or document.
Excel is a powerful tool to calculate and handle numerical data. In this Excel tutorial, you will explore 2 ways to convert currency to words: using VBA macro and applying an Excel formula.
In the following image, you have a dataset of several amounts that you want to convert to words. Let’s learn how to accomplish that from the section below.
Creating User-Defined Function Using VBA
Using VBA code allows users to create user-defined functions based on their requirements. Similarly, a currency amount can be converted to words using this approach. Follow these steps to convert currency to words using VBA code:
Step 1: Create a Function in VBA Module
- Go to the Developer tab > Code group > Visual Basic.
You can also press Alt+F11 keys to launch the VBA window.
The Microsoft Visual Basic for Applications window will appear. - In the VBA window, go to Insert tab > Module.
- Insert 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 the Save icon.
The Save As window appears. - Select Excel Macro-Enabled Workbook for Save as type > Save.
Thus, you have created a new function called SpellNumber through VBA code.
Step 2: Apply the User Defined Function
- Go back to the workbook and select a blank cell.
- Insert the formula:
=SpellNumber(B5)
Insert input cell in place of B5. - Press Enter.
Thus, the currency will be converted to words as below.
- Drag the Fill Handle down the column.
As a result, all the currency amounts in the dataset will be converted to words as follows.
Applying Excel Formula
You can also apply a formula to convert the currency to words in Excel. However, in this case, only the integers are converted properly and decimal conversion can result in errors. The advantage of this formula is that you can convert integers up to 100 billion (Source: HaroonSid).
Here’s how you can convert integers to words using Excel formula:
- Select a blank cell.
- Insert 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")&"","")))))))
Insert input cell in place of B5. - Press Enter. Thus, you will be able to convert the integer to words as below.
- Drag the Fill Handle down the column.
Finally, all the amounts in the dataset will be converted to words as follows.
Download Practice Workbook
You can download our practice workbook from below:
Conclusion
In some scenarios, numerical figures alone may not be sufficient, particularly when conveying financial information comprehensively. This is when the necessity to convert currency into words in Excel becomes apparent. This tutorial demonstrates 2 ways to do so by using VBA and by applying Excel formula. If you have any further queries, feel free to leave a comment below.
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. You can adjust the code to match your requirements.
Can I use this method for different currencies and locales?
Yes, you will have to modify the VBA code or localization settings to suit your specific requirements.
Are there any limitations to these methods?
Using the Excel formula can result in errors for decimal conversion and does not display currency names. However, using VBA functions can overcome both the issues.
<< 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