Whether you’re writing invoices, issuing checks or preparing finance statements, converting currencies like peso in words sometimes is essential in Excel. But unfortunately, excel doesn’t have a built-in function to perform this task.
In this case, by using a simple Excel VBA (Visual Basic for Applications) macro, you can create your own custom function that will do this directly. Let’s find out how it does.
Convert numbers into words in Excel with pesos format using the following steps.
➤ Hit Alt + F11 to open the VBA editor.
➤ Go to Insert > Module.
➤ Put the VBA code into the module window.
➤ The formula should be used in a cell such as:
=NumberToWords(C2)
➤ Press Enter.
This will make the amount in cell C2 turn into the complete words of One Thousand Two Hundred Fifty Pesos and Seventy-Five Centavos. And in addition to this basic version, we will learn how to format the output, format the currency language, and more. Let’s dive into the what’s what of the tutorial.
Using VBA for Macro Code to Convert Number to Words in Excel
This would be the easiest and most effective method to convert numbers into words in excel, especially while working with currencies like Philippine Peso. Additionally, a custom VBA macro allows us to convert whole numbers and decimal values such as 1250.75 into readable words like One Thousand Two Hundred Fifty Pesos and Seventy-Five Centavos.
However, below is a sample dataset where we have invoice numbers, customer names, transaction amounts in Peso, and a separate column that displays the equivalent amount in words. The goal is to automate this conversion using a reusable custom function written in VBA.
So, let’s convert the numbers from Column C in words in Column D.
Steps:
➤ Open the VBA editor by pressing the Alt + F11 from the keyboard while keeping the Excel open.
➤ Now in the editor, go to the Insert > Module menu. A blank code window will appear.
➤ In the window, copy and paste the following VBA macro we’ve already created for you.
Function NumberToWords(ByVal MyNumber)
Dim Pesos, Centavos, Temp
Dim DecimalPlace, Count
ReDim Place(9) As String
Place(2) = " Thousand "
Place(3) = " Million "
Place(4) = " Billion "
Place(5) = " Trillion "
' Convert MyNumber to string and find decimal place.
MyNumber = Trim(Str(MyNumber))
DecimalPlace = InStr(MyNumber, ".")
If DecimalPlace > 0 Then
Centavos = 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 Pesos = Temp & Place(Count) & Pesos
If Len(MyNumber) > 3 Then
MyNumber = Left(MyNumber, Len(MyNumber) - 3)
Else
MyNumber = ""
End If
Count = Count + 1
Loop
NumberToWords = Application.Trim(Pesos)
If NumberToWords = "" Then
NumberToWords = "Zero Pesos"
Else
NumberToWords = NumberToWords & " Pesos"
End If
If Centavos <> "" Then
NumberToWords = NumberToWords & " and " & Centavos & " Centavos"
End If
End Function
Private Function GetHundreds(ByVal MyNumber)
Dim Result As String
If Val(MyNumber) = 0 Then Exit Function
MyNumber = Right("000" & MyNumber, 3)
' Convert the hundreds place.
If Mid(MyNumber, 1, 1) <> "0" Then
Result = GetDigit(Mid(MyNumber, 1, 1)) & " Hundred "
End If
' Convert the tens and ones place.
If Mid(MyNumber, 2, 1) <> "0" Then
Result = Result & GetTens(Mid(MyNumber, 2))
Else
Result = Result & GetDigit(Mid(MyNumber, 3))
End If
GetHundreds = Result
End Function
Private Function GetTens(TensText)
Dim Result As String
If Val(Left(TensText, 1)) = 1 Then
Select Case Val(TensText)
Case 10: Result = "Ten"
Case 11: Result = "Eleven"
Case 12: Result = "Twelve"
Case 13: Result = "Thirteen"
Case 14: Result = "Fourteen"
Case 15: Result = "Fifteen"
Case 16: Result = "Sixteen"
Case 17: Result = "Seventeen"
Case 18: Result = "Eighteen"
Case 19: Result = "Nineteen"
Case Else
End Select
Else
Select Case Val(Left(TensText, 1))
Case 2: Result = "Twenty "
Case 3: Result = "Thirty "
Case 4: Result = "Forty "
Case 5: Result = "Fifty "
Case 6: Result = "Sixty "
Case 7: Result = "Seventy "
Case 8: Result = "Eighty "
Case 9: Result = "Ninety "
Case Else
End Select
Result = Result & GetDigit(Right(TensText, 1))
End If
GetTens = Result
End Function
Private Function GetDigit(Digit)
Select Case Val(Digit)
Case 1: GetDigit = "One"
Case 2: GetDigit = "Two"
Case 3: GetDigit = "Three"
Case 4: GetDigit = "Four"
Case 5: GetDigit = "Five"
Case 6: GetDigit = "Six"
Case 7: GetDigit = "Seven"
Case 8: GetDigit = "Eight"
Case 9: GetDigit = "Nine"
Case Else: GetDigit = ""
End Select
End Function
➤ Once you paste the code, it will appear on the screen as the image shows below.
➤ Now Save the code while choosing the type to Excel Macro – Enabled Workbook.
➤ After that, go back to the workbook you were working on. You can simply do so by pressing Alt + Q on your keyboard.
➤ Now insert the following formula in Cell C2 using the NumberToWords function.
=NumberToWords(C2)
➤ Press Enter and the formula will return the result as the given picture.
➤ You can also drag the Auto Fill Handle from the cell C2 to Cell11 and the results for existing cells will appear.
Formatting Tips after Converting Numbers into Words
Now that we’ve converted numbers into words pesos, let’s learn how to format them for better presentation. Basically, there are two different ways to do so. Whether we can make the output Uppercase or Lower case or add a currency suffix at the end. So, let’s dive into the deeper of this discussion.
Making the Output Uppercase or Lowercase
By default, the NumberToWords function returns the result in the title case. If you want to change the letter casing, you can use Excel’s built-in text functions.
To Make the Output All Uppercase
Steps:
➤ Insert the formula in the Cell D2 as follows:
=UPPER(NumberToWords(C2))
➤ Tap Enter. The result will be in all Uppercases.
To Make the Output All Lower Cases
Steps:
➤ Type the below formula in the cell D2:
=LOWER(NumberToWords(C2))
➤ Press Enter and the result will be shown as the following image.
Adding a Currency Suffix
Sometimes you may also want a currency suffix like Only at the end of the text. Fortunately, we can also do so with some simple steps as follows.
Steps:
➤ Put the formula as follows into the D2 cell:
=NumberToWords(C2) & ” Only”
➤ Now press Enter and you’ll get the required result.
Frequently Asked Questions
Can I Convert Number to Words Automatically for Every Number in a Column in Excel?
Yes, definitely. After applying the VBA function, just copy the formula down the column and it will be set automatically to all cells.
Is This VBA Method Applicable on Excel for Mac or Excel Online?
VBA Macros are applicable on Windows and Mac while on Mac it may need some adjustments. But for Excel Online, it doesn’t support VBA. So, you’ll need a manual or add-in solution.
Will changing my regional settings to the Philippines automatically add Peso in words?
No. Regional settings only affect number formatting (currency symbol ₱), not converting numbers to words. You must still use a VBA or custom solution.
Concluding Words
Using a simple VBA macro you can harness the power of Excel to translate numbers to words in Peso format including Centavos. This can be most useful in a financial application such as accounting, billing, payroll, invoicing or legal expenses where currency values are output. Hopefully, this guide has helped you to learn how to convert numbers in words in Excel peso.