Excel+VBA

Excel+VBA Learn MS Excel Functions, Formulas, Macros, VBA, Tricks, Tips and more...

🤩Convert numbers into words...https://www.facebook.com/share/r/1A5PmdkP55/?mibextid=oFDknkOption ExplicitFunction Number...
03/28/2025

🤩Convert numbers into words...

https://www.facebook.com/share/r/1A5PmdkP55/?mibextid=oFDknk

Option Explicit
Function NumbersToWords(ByVal ValueToConvert)
If ValueToConvert > 999999999999999 # Then
NumbersToWords = "Value to convert is more than 999,999,999,999,999.00"
Else
Dim MyWords, Temp, ValueToConvertDecimal
Dim DecimalPlace, Count
ReDim Place(9) As String

Place(2) = " Thousand "
Place(3) = " Million "
Place(4) = " Billion "
Place(5) = " Trillion "

If ValueToConvert < 0 Then
ValueToConvert = ValueToConvert * -1
End If

ValueToConvert = Trim(str(ValueToConvert))

If InStr(ValueToConvert, ".") = 0 Then
ValueToConvertDecimal = ""
Else
ValueToConvertDecimal = " And " & Left(Mid(ValueToConvert, InStr(ValueToConvert, ".") + 1) & "00", 2) & "/100"
End If

DecimalPlace = InStr(ValueToConvert, ".")

If DecimalPlace > 0 Then
ValueToConvert = Trim(Left(ValueToConvert, DecimalPlace - 1))
End If

Count = 1

Do While ValueToConvert ""
Temp = GetHundreds(Right(ValueToConvert, 3))
If Temp "" Then MyWords = Temp & Place(Count) & MyWords
If Len(ValueToConvert) > 3 Then
ValueToConvert = Left(ValueToConvert, Len(ValueToConvert) - 3)
Else
ValueToConvert = ""
End If

Count = Count + 1
Loop

Select Case MyWords
Case ""
MyWords = "Zero"
Case "One"
MyWords = "One"
Case Else
MyWords = MyWords
End Select

NumbersToWords = MyWords & ValueToConvertDecimal
End If
End Function

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

Function GetTens(TensText)
Dim Result As String
Result = ""

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

Function GetHundreds(ByVal ValueToConvert)
Dim Result As String
If Val(ValueToConvert) = 0 Then Exit Function
ValueToConvert = Right("000" & ValueToConvert, 3)

If Mid(ValueToConvert, 1, 1) "0" Then
Result = GetDigit(Mid(ValueToConvert, 1, 1)) & " Hundred "
End If


If Mid(ValueToConvert, 2, 1) "0" Then
Result = Result & GetTens(Mid(ValueToConvert, 2))
Else
Result = Result & GetDigit(Mid(ValueToConvert, 3))
End If

GetHundreds = Result
End Function

Anyone? 🤔💬👀
03/21/2025

Anyone? 🤔💬👀

09/04/2023
07/27/2023

SUMIF exclude hidden cells using OFFSET, ROW, INDIRECT, COUNTA, SUBTOTAL and SUM functions...

06/23/2023

😎Automatically Show Dropdowm List - 🖱 Click free...


06/08/2023

😎Auto Protect/Unprotect Worksheet with password in VBA...

06/05/2023

Calendar Date Picker in VBA

05/29/2023

How to create dependent drop down list using Data Validation and INDIRECT function.

Address

California City, CA

Alerts

Be the first to know and let us send you an email when Excel+VBA posts news and promotions. Your email address will not be used for any other purpose, and you can unsubscribe at any time.

Contact The Business

Send a message to Excel+VBA:

Share