Categories: Microsoft Excel

SpellNumber Function Without Currency In Excel

SpellNumber Without Currency is a manually created function through VBA Programming to change a number to written text. In other words, it converts a numeric value in excel into English words without currency.

The SpellNumber macro spells the numeric value to words as the name suggests. There is no direct function in Microsoft Excel to perform the above action.

However, as many and many users demanded, Microsoft has created and published the special VBA macro code on their website for SpellNumber with Currency.

For example;

If I need to display $ 2,345.50 as “Dollar Two Thousand Three Hundred Forty-Five and Fifty Cents” then you can use the code available on Microsoft website.

But If I need to display 2,345.50 to be displayed as ” Two Thousand Three Hundred Forty-Five Point Five ” then we need to use the SpellNumber Function Without Currency.

We have edited the same code with some changes for the required result. In this article, we will discuss the whole step by step process on how to create this SpellNumber Function Without Currency using the VBA Function.

How To Create SpellNumber Function Without Currency

Step 1: Start Microsoft Excel.

Step 2: Go To Developer Tab. Click “Visual Basic” under Code.

Step 3: Under the Insert menu, click Module.

Step 4: Copy and Paste the below code into the Module sheet.

Code



This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters


Option Explicit
'Main Function www.ExcelDataPro.com
Function SpellNumber1(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 = GetDigit(Left(Mid(MyNumber, DecimalPlace + 1) & _
"00", 1)) & " " & GetDigit(Left(Mid(MyNumber, DecimalPlace + 2) & _
"00", 1))
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 Cents
Case ""
Cents = ""
Case "One"
Cents = " Point One "
Case Else
Cents = " Point " & Cents & " "
End Select
SpellNumber1 = 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
view raw

spellnumber1.vb

hosted with ❤ by GitHub

Step 5: Save the workbook using Ctrl+S. Microsoft Excel will display the following message: “The following features cannot be saved in macro-free workbook” as you file now consists of a macro. Click “No”.

Following dialog box will appear. Select “Save As”.

From the drop-down menu select the “Save as type” as “Excel macro-enabled workbook”.

Now, your workbook consists of the new SpellNumber Function. Please keep in mind that this function will only be available in this workbook.

You need to paste the code for each workbook by following the above-mentioned steps.

Every time you will open this workbook or any other macro-enabled workbook, a security warning will appear below the ribbon. Select “Enable this content” and press enter or click “OK”.

Screenshots are given below for your ready reference:

Let us use this code in a workbook and see the results.

In column A, I have inserted the numbers you that I need to change into words.

In column B press “=” sign and write SpellNumber.

Select from the SpellNumber and give the cell reference.

The workbook displays the following results:

We thank our readers for liking, sharing and following us on different social media platforms.

If you have any queries or suggestions please share in the comment section below. I will be more than happy to assist you.

Shabbir Bhimani

I have worked in Excel and like to share functional excel templates at ExcelDataPro.

Share
Published by
Shabbir Bhimani

Recent Posts

Download UK VAT Taxable Turnover Calculator Excel Template

To simplify the process, we have created a simple and easy UK VAT Taxable Turnover…

4 years ago

Step By Step Guide TO UK VAT Registration Process

Every business has to register for VAT with HM Revenue and Customs if their VAT…

4 years ago

Download UK VAT Dual Currency Invoice Excel Template

We have created the UK VAT Dual Currency Invoice excel template with predefined formulas that…

4 years ago

Download UK VAT Purchase Register Excel Template

We have created a simple and easy UK VAT Purchase Register Excel Template with predefined…

4 years ago

Download UK VAT Sales Register Excel Template

We have created a simple and easy UK VAT Sales Register Excel Template with predefined…

4 years ago

Download UK VAT Progress Billing Invoice Excel Template

We have created a ready to use UK VAT Progress Billing Invoice template in excel…

4 years ago