How to Convert Numbers to Words in Excel

Excel does not have a built-in function to convert numbers to words. However, you can achieve this using a VBA (Visual Basic for Applications) macro. Here's how to do it:

Step 1: Enable the Developer Tab

  1. Open Excel.
  2. Go to File > Options > Customize Ribbon.
  3. Under the Main Tabs section, check the Developer checkbox and click OK.

Step 2: Add the VBA Code

  1. Go to the Developer tab and click on Visual Basic.
  2. In the VBA editor, click Insert > Module.
  3. Paste the following code into the module:
vba
Function NumberToWords(ByVal MyNumber) Dim Units As String, Tens As String Dim Temp As String, DecimalPlace As Integer, Count As Integer Dim Place(9) As String Dim DecimalPart As String, IntegerPart As String Place(2) = " Thousand": Place(3) = " Million": Place(4) = " Billion": Place(5) = " Trillion" ' String to hold number in words MyNumber = Trim(Str(MyNumber)) ' Handle decimals DecimalPlace = InStr(MyNumber, ".") If DecimalPlace > 0 Then IntegerPart = Left(MyNumber, DecimalPlace - 1) DecimalPart = Mid(MyNumber, DecimalPlace + 1) Else IntegerPart = MyNumber End If ' Handle integers Count = 1 Do While IntegerPart <> "" Temp = GetHundreds(Right(IntegerPart, 3)) If Temp <> "" Then Units = Temp & Place(Count) & Units If Len(IntegerPart) > 3 Then IntegerPart = Left(IntegerPart, Len(IntegerPart) - 3) Else IntegerPart = "" End If Count = Count + 1 Loop ' Handle decimals If DecimalPart <> "" Then Tens = " and " & GetHundreds(DecimalPart) & " Cents" End If NumberToWords = Trim(Units & Tens) End Function Function GetHundreds(ByVal MyNumber) Dim Result As String Dim SingleDigit(9) As String, TensDigit(9) As String, Teens(9) As String SingleDigit(0) = "": SingleDigit(1) = " One": SingleDigit(2) = " Two": SingleDigit(3) = " Three" SingleDigit(4) = " Four": SingleDigit(5) = " Five": SingleDigit(6) = " Six" SingleDigit(7) = " Seven": SingleDigit(8) = " Eight": SingleDigit(9) = " Nine" TensDigit(0) = "": TensDigit(2) = " Twenty": TensDigit(3) = " Thirty" TensDigit(4) = " Forty": TensDigit(5) = " Fifty": TensDigit(6) = " Sixty" TensDigit(7) = " Seventy": TensDigit(8) = " Eighty": TensDigit(9) = " Ninety" Teens(0) = " Ten": Teens(1) = " Eleven": Teens(2) = " Twelve" Teens(3) = " Thirteen": Teens(4) = " Fourteen": Teens(5) = " Fifteen" Teens(6) = " Sixteen": Teens(7) = " Seventeen": Teens(8) = " Eighteen" Teens(9) = " Nineteen" MyNumber = Right("000" & MyNumber, 3) If Val(Left(MyNumber, 1)) > 0 Then Result = SingleDigit(Val(Left(MyNumber, 1))) & " Hundred" End If If Val(Mid(MyNumber, 2, 1)) > 1 Then Result = Result & TensDigit(Val(Mid(MyNumber, 2, 1))) & SingleDigit(Val(Right(MyNumber, 1))) ElseIf Val(Mid(MyNumber, 2, 1)) = 1 Then Result = Result & Teens(Val(Right(MyNumber, 1))) Else Result = Result & SingleDigit(Val(Right(MyNumber, 1))) End If GetHundreds = Result End Function

Step 3: Use the Function in Excel

  1. Close the VBA editor and return to Excel.
  2. Save the workbook as a Macro-Enabled Workbook (with .xlsm extension).
  3. In a cell, use the function like this:
    scss
    =NumberToWords(A1)
    Replace A1 with the cell containing the number you want to convert.

Example

  • If A1 contains 1234.56, the formula =NumberToWords(A1) will return: "One Thousand Two Hundred Thirty-Four and Fifty-Six Cents"
Share:

0 Comments:

Post a Comment