Fun.Think.Wonder - Mabzicle

Microsoft Excel is a great spreadsheet software program for computing and sorting out data. But has a limitation...

Microsoft Excel is an excellent spreadsheet software program for computing and sorting out data. Well, it is roughly designed to process large data arrays after its predecessor —  VisiCalc.

Short history: In 1928, a Harvard Business school student, Daniel, Bricklin has this idea for a visible calculator. Later, Bricklin and Bob Frankston created the so-called "First Killer" application for PC; that is VisiCalc. Microsoft Excel indeed solves the accounting records problem. Thus, it's quite one of the best tools among users including me.

But there is a limitation with this powerful program, sometimes, we need to convert number currency (Peso, Dollar, Euros, GPC, pounds, etc.) to English Words, and doesn't have this built-in function.

Examples:
• 123 to "one hundred and twenty-three."
• \$123 to "one hundred and twenty-three dollars."
• \$123.50 to "one hundred and twenty-three dollars and fifty cents."
• Php 123.00 to "one hundred and twenty-three pesos."
• Php 123.50 to "one hundred and twenty-three pesos and fifty centavos."
However, the good thing is, they made a function module. (found on https://support.office.com/en-us/article/Convert-numbers-into-words-a0d166fb-e1ea-4090-95c8-69442cd55d98) Honestly, it gives me a great deal with it. I don't need to reinvent the wheel from scratch.

Here it goes:

HOW TO: Convert Numbers(Currency) Into English Words In Excel

1. Open Microsoft Excel
2. Press ALT+F11 on your keyboard to open the Microsoft Visual Basic window.
3. Then, Choose the Insert menu then click Module
4. Copy the following code and paste on that module window

``````Option Explicit
'Main Function
Function SpellNumber(ByVal MyNumber)
Dim Dollars, Cents, Temp
Dim DecimalPlace, Count
ReDim Place(9) As String
Place(2) = " Thousand "
Place(3) = " Million "
Place(4) = " Billion "
Place(5) = " Trillion "
' String representation of amount.
MyNumber = Trim(Str(MyNumber))
' Position of decimal place 0 if none.
DecimalPlace = InStr(MyNumber, ".")
' Convert cents and set MyNumber to dollar amount.
If DecimalPlace > 0 Then
Cents = 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 Dollars = Temp & Place(Count) & Dollars
If Len(MyNumber) > 3 Then
MyNumber = Left(MyNumber, Len(MyNumber) - 3)
Else
MyNumber = ""
End If
Count = Count + 1
Loop
Select Case Dollars
Case ""
Dollars = "No Dollars"
Case "One"
Dollars = "One Dollar"
Case Else
Dollars = Dollars & " Dollars"
End Select
Select Case Cents
Case ""
Cents = " and No Cents"
Case "One"
Cents = " and One Cent"
Case Else
Cents = " and " & Cents & " Cents"
End Select
SpellNumber = Dollars & Cents
End Function

' Converts a number from 100-999 into text
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

' Converts a number from 10 to 99 into text.
Function GetTens(TensText)
Dim Result As String
Result = ""           ' Null out the temporary function value.
If Val(Left(TensText, 1)) = 1 Then   ' If value between 10-19...
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                                 ' If value between 20-99...
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))  ' Retrieve ones place.
End If
GetTens = Result
End Function

' Converts a number from 1 to 9 into text.
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``````

Take note: the currency is a dollar, therefore, depends on your location, you need to change the text above. The function yields to these results:

Notice that if there is no decimal point, it will add "No Cents." In real-world, there is no need to put such words. Ideally, the "only" word shall put at the last of those sentences.

You can still edit it in the code above.

Tip: No need to manually type over again that function. All you need is to point and drag down until it displays the result. See below in action.

You will notice that it is not capitalized. If you wish to convert it to ALL UPPER CASE then right thing, Excel has built-in ALL CAPS. Thanks to function UPPER().

5. Then you close that window. In your Excel window, try to type =SpellNumber you will notice if successfully embedded, display the function.

By the way, the function is called SpellNumber(Cell) (try to see above code)

6. There you have it! After accomplishing the desired output, you need to SAVE it to a macro-enabled format. At first, it will prompt something like this:

As per instruction, you need to save it in a macro-enabled to include the function code. Therefore, click NO, and start choosing a .xlsm file format.

Final Thoughts
If you have comments and suggestions, you may cast it below. Thank you! Name

ltr
item
Mabzicle: HOW TO: Convert Numbers(Currency) Into English Words In Excel
HOW TO: Convert Numbers(Currency) Into English Words In Excel
Microsoft Excel is a great spreadsheet software program for computing and sorting out data. But has a limitation...
https://2.bp.blogspot.com/-B2NbSrQLXEs/Vqwh15iCf3I/AAAAAAAASI8/xMIYQs1QlSg/s640/EXCEL%2BCONVERSION.png
https://2.bp.blogspot.com/-B2NbSrQLXEs/Vqwh15iCf3I/AAAAAAAASI8/xMIYQs1QlSg/s72-c/EXCEL%2BCONVERSION.png
Mabzicle
https://www.mabzicle.com/2016/01/convert-numbers-to-word-in-microsoft-excel.html
https://www.mabzicle.com/
https://www.mabzicle.com/
https://www.mabzicle.com/2016/01/convert-numbers-to-word-in-microsoft-excel.html
false
219040821802169216
UTF-8