- Get link
- X
- Other Apps
- Get link
- X
- Other Apps
There are no features or formulas can help you to solve this task directly in Excel, but you can create a User Defined Function to finish it. Please do with following steps:
1. Hold down the ALT + F11 keys, and it opens the Microsoft Visual Basic for Applications Window.
2. Click Insert > Module, and paste the following code in the Module Window.
Function NumberstoWords(ByVal MyNumber)'Update by ExtendofficeDim xStr As StringDim xFNum As IntegerDim xStrPointDim xStrNumberDim xPoint As StringDim xNumber As StringDim xP() As VariantDim xDPDim xCnt As IntegerDim xResult, xT As StringDim xLen As IntegerOn Error Resume NextxP = Array("", "Thousand ", "Million ", "Billion ", "Trillion ", " ", " ", " ", " ")xNumber = Trim(Str(MyNumber))xDP = InStr(xNumber, ".")xPoint = ""xStrNumber = ""If xDP > 0 ThenxPoint = " point "xStr = Mid(xNumber, xDP + 1)xStrPoint = Left(xStr, Len(xNumber) - xDP)For xFNum = 1 To Len(xStrPoint)xStr = Mid(xStrPoint, xFNum, 1)xPoint = xPoint & GetDigits(xStr) & " "Next xFNumxNumber = Trim(Left(xNumber, xDP - 1))End IfxCnt = 0xResult = ""xT = ""xLen = 0xLen = Int(Len(Str(xNumber)) / 3)If (Len(Str(xNumber)) Mod 3) = 0 Then xLen = xLen - 1Do While xNumber <> ""If xLen = xCnt ThenxT = GetHundredsDigits(Right(xNumber, 3), False)ElseIf xCnt = 0 ThenxT = GetHundredsDigits(Right(xNumber, 3), True)ElsexT = GetHundredsDigits(Right(xNumber, 3), False)End IfEnd IfIf xT <> "" ThenxResult = xT & xP(xCnt) & xResultEnd IfIf Len(xNumber) > 3 ThenxNumber = Left(xNumber, Len(xNumber) - 3)ElsexNumber = ""End IfxCnt = xCnt + 1LoopxResult = xResult & xPointNumberstoWords = xResultEnd FunctionFunction GetHundredsDigits(xHDgt, xB As Boolean)Dim xRStr As StringDim xStrNum As StringDim xStr As StringDim xI As IntegerDim xBB As BooleanxStrNum = xHDgtxRStr = ""On Error Resume NextxBB = TrueIf Val(xStrNum) = 0 Then Exit FunctionxStrNum = Right("000" & xStrNum, 3)xStr = Mid(xStrNum, 1, 1)If xStr <> "0" ThenxRStr = GetDigits(Mid(xStrNum, 1, 1)) & "Hundred "ElseIf xB ThenxRStr = "and "xBB = FalseElsexRStr = " "xBB = FalseEnd IfEnd IfIf Mid(xStrNum, 2, 2) <> "00" ThenxRStr = xRStr & GetTenDigits(Mid(xStrNum, 2, 2), xBB)End IfGetHundredsDigits = xRStrEnd FunctionFunction GetTenDigits(xTDgt, xB As Boolean)Dim xStr As StringDim xI As IntegerDim xArr_1() As VariantDim xArr_2() As VariantDim xT As BooleanxArr_1 = Array("Ten ", "Eleven ", "Twelve ", "Thirteen ", "Fourteen ", "Fifteen ", "Sixteen ", "Seventeen ", "Eighteen ", "Nineteen ")xArr_2 = Array("", "", "Twenty ", "Thirty ", "Forty ", "Fifty ", "Sixty ", "Seventy ", "Eighty ", "Ninety ")xStr = ""xT = TrueOn Error Resume NextIf Val(Left(xTDgt, 1)) = 1 ThenxI = Val(Right(xTDgt, 1))If xB Then xStr = "and "xStr = xStr & xArr_1(xI)ElsexI = Val(Left(xTDgt, 1))If Val(Left(xTDgt, 1)) > 1 ThenIf xB Then xStr = "and "xStr = xStr & xArr_2(Val(Left(xTDgt, 1)))xT = FalseEnd IfIf xStr = "" ThenIf xB ThenxStr = "and "End IfEnd IfIf Right(xTDgt, 1) <> "0" ThenxStr = xStr & GetDigits(Right(xTDgt, 1))End IfEnd IfGetTenDigits = xStrEnd FunctionFunction GetDigits(xDgt)Dim xStr As StringDim xArr_1() As VariantxArr_1 = Array("Zero ", "One ", "Two ", "Three ", "Four ", "Five ", "Six ", "Seven ", "Eight ", "Nine ")xStr = ""On Error Resume NextxStr = xArr_1(Val(xDgt))GetDigits = xStrEnd Function 3. Save and close this code and go back the worksheet, in a blank cell, enter this formula =NumberstoWords(A2)( A2 is the cell you want to convert the number to an English word), see screenshot: 
Convert numbers to currency words with User Defined Function
1. Hold down the ALT + F11 keys, and it opens the Microsoft Visual Basic for Applications Window.
2. Click Insert > Module, and paste the following code in the Module Window.
Function SpellNumberToEnglish(ByVal pNumber)'Update by ExtendofficeDim Dollars, Centsarr = Array("", "", " Thousand ", " Million ", " Billion ", " Trillion ")pNumber = Trim(Str(pNumber))xDecimal = InStr(pNumber, ".")If xDecimal > 0 Then Cents = GetTens(Left(Mid(pNumber, xDecimal + 1) & "00", 2)) pNumber = Trim(Left(pNumber, xDecimal - 1))End IfxIndex = 1Do While pNumber <> "" xHundred = "" xValue = Right(pNumber, 3) If Val(xValue) <> 0 Then xValue = Right("000" & xValue, 3) If Mid(xValue, 1, 1) <> "0" Then xHundred = GetDigit(Mid(xValue, 1, 1)) & " Hundred " End If If Mid(xValue, 2, 1) <> "0" Then xHundred = xHundred & GetTens(Mid(xValue, 2)) Else xHundred = xHundred & GetDigit(Mid(xValue, 3)) End If End If If xHundred <> "" Then Dollars = xHundred & arr(xIndex) & Dollars End If If Len(pNumber) > 3 Then pNumber = Left(pNumber, Len(pNumber) - 3) Else pNumber = "" End If xIndex = xIndex + 1LoopSelect Case Dollars Case "" Dollars = "No Dollars" Case "One" Dollars = "One Dollar" Case Else Dollars = Dollars & " Dollars"End SelectSelect Case Cents Case "" Cents = " and No Cents" Case "One" Cents = " and One Cent" Case Else Cents = " and " & Cents & " Cents"End SelectSpellNumberToEnglish = Dollars & CentsEnd FunctionFunction GetTens(pTens)Dim Result As StringResult = ""If Val(Left(pTens, 1)) = 1 Then Select Case Val(pTens) 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 SelectElseSelect Case Val(Left(pTens, 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 ElseEnd SelectResult = Result & GetDigit(Right(pTens, 1))End IfGetTens = ResultEnd FunctionFunction GetDigit(pDigit)Select Case Val(pDigit) 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 SelectEnd Function 3. Save this code and go back the worksheet, in a blank cell, enter this formula =SpellNumberToEnglish(A2)( A2
is the cell you want to convert the number to an English currency
word), and then drag the fill handle down to the cells that you want to
apply this formula, all the numbers have been spelt out into English
currency words, see screenshot:

- Get link
- X
- Other Apps
Comments
Post a Comment