# How to Use Spell Number in Excel (2 Suitable Examples)

Get FREE Advanced Excel Exercises with Solutions!

Sometimes you need to convert the number into a text value. In that case, you can use the spell number function in Excel. Though it is not a built-in function in Excel, you can add it by using the VBA code. In VBA code, you can utilize the spell number function for currency function or without currency purposes. In article will show you how to use the spell number in Excel effectively. We will show the proper explanation of the spell number function in the VBA code. I hope you find this article exciting.

As the spell number function is used to convert numbers into texts., you can use the spell number for two different purposes. One is for converting into the currency of several countries and the other is for a simple case. Both of the examples provide you with useful details through which you can have a proper overview of the spell number function.

## 1. Using Spell Number with Currency in Excel

Our first example is based on the use of the spell number with currency in Excel. In this example, we would like to create a VBA code with the spell number function. In this code, we will define the currency of several countries. So, when you use the spell number in a cell and define the country name, it will return the text form of that given currency. To have a proper understanding of the code, we will give an explanation of the code. If you want to open the Visual Basic window, you have to get the Developer tab on the ribbon.

Steps

• First, go to the Developer tab on the ribbon.
• Then, select the Visual Basic option from the Code group. • It will open up the Visual Basic window.
• Then, go to the Insert tab at the top.
• After that, select the Module option. • As a result, a Module code window will appear.
• Write down the following code.
``````Option Explicit
Function SpellNumberX(ByVal MyNum, Optional MyCurr As String = "")
Dim Dllr, Cts, Temp
Dim DeciPlace, CountX
ReDim Place(9) As String
Place(2) = " Thousand "
Place(3) = " Million "
Place(4) = " Billion "
Place(5) = " Trillion "
MyNum = Trim(Str(MyNum))
DeciPlace = InStr(MyNum, ".")
If DeciPlace > 0 Then
Cts = GetTens(Left(Mid(MyNum, DeciPlace + 1) & _
"00", 2))
MyNum = Trim(Left(MyNum, DeciPlace - 1))
End If
CountX = 1
Do While MyNum <> ""
Temp = GetHundreds(Right(MyNum, 3))
If Temp <> "" Then Dllr = Temp & Place(CountX) & Dllr
If Len(MyNum) > 3 Then
MyNum = Left(MyNum, Len(MyNum) - 3)
Else
MyNum = ""
End If
CountX = CountX + 1
Loop
Dim str_amount, str_amounts
Dim str_cent, str_Cts
Select Case UCase(MyCurr)
Case "EU"
str_amount = "Euro"
str_amounts = "Euros"
str_cent = "Cent"
str_Cts = "Cents"
Case "CA"
str_cent = "Cent"
str_Cts = "Cents"
Case "AU"
str_amount = "Australian Dollar"
str_amounts = "Australian Dollars"
str_cent = "Cent"
str_Cts = "Cents"
Case Else:
str_amount = "Dollar"
str_amounts = "Dollars"
str_cent = "Cent"
str_Cts = "Cents"
End Select
Select Case Dllr
Case ""
Dllr = "No " & str_amounts
Case "One"
Dllr = "One " & str_amount
Case Else
Dllr = Dllr & " " & str_amounts
End Select
Select Case Cts
Case ""
Cts = " and No " & str_Cts
Case "One"
Cts = " and One " & str_cent
Case Else
Cts = " and " & Cts & " " & str_Cts
End Select
SpellNumberX = Dllr & Cts
End Function
Function GetHundreds(ByVal MyNum)
Dim Result As String
If Val(MyNum) = 0 Then Exit Function
MyNum = Right("000" & MyNum, 3)
If Mid(MyNum, 1, 1) <> "0" Then
Result = GetDigit(Mid(MyNum, 1, 1)) & " Hundred "
End If
If Mid(MyNum, 2, 1) <> "0" Then
Result = Result & GetTens(Mid(MyNum, 2))
Else
Result = Result & GetDigit(Mid(MyNum, 3))
End If
GetHundreds = Result
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 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``````
• Then, close the Visual Basic

Spell Number for Dollars

First of all, we would like to show the spell number with currency for dollars. To do this, you need to follow the previous steps carefully. Then, follow the steps.

• First, select the cell where you want to use the spell number function.
• Then, write down the following formula.
`=SpellNumberX(B5)` • Press Enter to apply the formula. • Then, drag the Fill Handle icon down the column. Spell Number for Euros

Next, we would like to show the spell number with currency for Euros. Basically, we set the layout in the VBA code. We just need to define the Euros as ‘EU’. Then, follow the steps carefully.

• First, select the cell where you want to use the spell number function.
• Then, write down the following formula.
`=SpellNumberX(B5,"EU")` • Press Enter to apply the formula. • Then, drag the Fill Handle icon down the column. Spell Number for Australian Dollars

Next, we would like to show the spell number with currency for Australian Dollars. Basically, we set the layout in the VBA code. We just need to define the Euros as ‘AU’. Then, follow the steps carefully.

• First, select the cell where you want to use the spell number function.
• Then, write down the following formula.
`=SpellNumberX(B5,"AU")` • Press Enter to apply the formula. • Then, drag the Fill Handle icon down the column. Next, we would like to show the spell number with currency for Canadian Dollars. Basically, we set the layout in the VBA code. We just need to define the Euros as ‘CA’. Then, follow the steps carefully.

• First, select the cell where you want to use the spell number function.
• Then, write down the following formula.
`=SpellNumberX(B5,"CA")` • Press Enter to apply the formula. • Then, drag the Fill Handle icon down the column. 🔎 VBA Code Explanation:

``````Option Explicit
Function SpellNumberX(ByVal MyNum, Optional MyCurr As String = "")``````

First of all, define the function name and also define the value of the function.

``````Dim Dllr, Cts, Temp
Dim DeciPlace, CountX
ReDim Place(9) As String
Place(2) = " Thousand "
Place(3) = " Million "
Place(4) = " Billion "
Place(5) = " Trillion "``````

Next, declare the necessary variable for the macro. The String is a representation of the amount.

`` MyNum = Trim(Str(MyNum))``

Next, we trim the string value’s extra space.

``DeciPlace = InStr(MyNum, ".")``

After that, use the InStr function to find out the position of the sub-string within a string and set the position of the decimal place as 0 if none.

``````If DeciPlace > 0 Then
Cts = GetTens(Left(Mid(MyNum, DeciPlace + 1) & _
"00", 2))
MyNum = Trim(Left(MyNum, DeciPlace - 1))
End If
CountX = 1``````

Then, if the decimal place is greater than zero. Convert Cents and set Numbers to the dollar amount. If the criteria match then, set the countX as 1

``````Do While MyNum <> ""
Temp = GetHundreds(Right(MyNum, 3))
If Temp <> "" Then Dllr = Temp & Place(CountX) & Dllr
If Len(MyNum) > 3 Then
MyNum = Left(MyNum, Len(MyNum) - 3)
Else
MyNum = ""
End If
CountX = CountX + 1
Loop``````

Next, use the Do while loop, if the number is not blank.  Then, check if the temp is not blank. After that, define the dollar. Again check if the number is greater than 3 then, define the number value. Otherwise, it will return a blank. If the loop works, then, add the 1 to the previous countX and finish the loop.

``````Dim str_amount, str_amounts
Dim str_cent, str_Cts``````

Next, declare the necessary variable for the macro.

``````Select Case UCase(MyCurr)
Case "EU"
str_amount = "Euro"
str_amounts = "Euros"
str_cent = "Cent"
str_Cts = "Cents"``````

Then, define the case for the Euro currency. Here, you can assign how it can be shown for a specific condition.

``````Case "CA"
str_cent = "Cent"
str_Cts = "Cents"``````

Then, define the case for the Canadian currency. Here, you can assign how it can be shown for a specific condition.

``````Case "AU"
str_amount = "Australian Dollar"
str_amounts = "Australian Dollars"
str_cent = "Cent"
str_Cts = "Cents"``````

Then, define the case for the Australian currency. Here, you can assign how it can be shown for a specific condition.

`````` Case Else:
str_amount = "Dollar"
str_amounts = "Dollars"
str_cent = "Cent"
str_Cts = "Cents"
End Select``````

Besides those three cases, if you use the value in the spell number function, it will return the dollar currency. Then, end the selection.

``````Select Case Dllr
Case ""
Dllr = "No " & str_amounts
Case "One"
Dllr = "One " & str_amount
Case Else
Dllr = Dllr & " " & str_amounts
End Select``````

After that, select the dollar case. If the case is blank, then it will return No. For case one, it returns one dollar. Otherwise, it will return the dollar amounts.

``````Select Case Cts
Case ""
Cts = " and No " & str_Cts
Case "One"
Cts = " and One " & str_cent
Case Else
Cts = " and " & Cts & " " & str_Cts
End Select``````

For cents case, if the case is blank, then it will return No. For case one, it returns one dollar. Otherwise, it will return the cents amounts.

``````SpellNumberX = Dllr & Cts
End Function``````

Finally, when you use the spell function and define the numbered cell, it will return the value of both dollars and cents.

``Function GetHundreds(ByVal MyNum)``

Then, we define the function GetHundreds.

``Dim Result As String``

Next, declare the necessary variable for the macro.

``````If Val(MyNum) = 0 Then Exit Function
MyNum = Right("000" & MyNum, 3)``````

If the val function returns a zero number from the string, then the function will end.

`````` If Mid(MyNum, 1, 1) <> "0" Then
Result = GetDigit(Mid(MyNum, 1, 1)) & " Hundred "
End If``````

The mid function returns a specific number of characters from the string. Here, the mid function extracts the first character. If this is not equal to zero or not. Then, define the result for it.

``````If Mid(MyNum, 2, 1) <> "0" Then
Result = Result & GetTens(Mid(MyNum, 2))
Else
Result = Result & GetDigit(Mid(MyNum, 3))
End If``````

Then, take the mid function and it starts from 2nd place and finishes after one character. Now, check if that is not equal to zero or not. Then, define the result with GetTens. Otherwise, it takes results using GetDigit.

``````GetHundreds = Result
End Function``````

Next, the GetHundreds take the result. After that, end the function.

``Function GetTens(TensText)``

Then, define the function GetTens for the macro.

``Dim Result As String``

Next, declare the necessary variable for the macro.

``Result = ""``

Define the result as null out of the temporary function value

``````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``````

Next, set the if condition. First, the left function returns the first character from the tensText. After that, Val function takes that return value and returns the number that is contained in that string. Finally, check if the number is equal to 1. If it meets the criterion, then, returns the defined case result. Finally, end the process.

``````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``````

Otherwise, If the value is between 20-99, It also goes to the case using the val and left function. Then, returns the defined case result. Finally, end the process.

``````Result = Result & GetDigit _
(Right(TensText, 1))
End If
GetTens = Result
End Function``````

Then, define the result with GetDigit. Next, using the Right function retrieves one’s place. Finally, end the function.

``Function GetDigit(Digit)``

To convert a number from 1 to 9 into text. Define the GetDigit function of the macro.

``````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``````

Then, select the case using the Val function. It returns numbers that are contained in a string. Then, check which case is applicable for that. Otherwise, returns as blank. Then, end the selection.

``End Function``

Finally, end the function of the macro

## 2. Using Spell Number Without Currency in Excel

Our first example is based on the use of the spell number without currency in Excel. In this example, we would like to create a VBA code with the spell number function. We want to convert numbers into texts. In that case, the currency will be neglected. To get a proper understanding of the code, we will give an explanation of the code. Follow the steps properly.

Steps

• First, go to the Developer tab on the ribbon.
• Then, select the Visual Basic option from the Code group. • It will open up the Visual Basic window.
• Then, go to the Insert tab at the top.
• After that, select the Module option. • As a result, a Module code window will appear.
• Write down the following code.
``````Option Explicit
Function SpellNumberY(ByVal MyNum)
Dim Dllr, Cts, Temp
Dim DeciPlace, CountX
ReDim Place(9) As String
Place(2) = " Thousand "
Place(3) = " Million "
Place(4) = " Billion "
Place(5) = " Trillion "
MyNum = Trim(Str(MyNum))
DeciPlace = InStr(MyNum, ".")
If DeciPlace > 0 Then
Cts = GetDigit(Left(Mid(MyNum, DeciPlace + 1) & _
"00", 1)) & " " & GetDigit(Left(Mid(MyNum, DeciPlace + 2) & _
"00", 1))
MyNum = Trim(Left(MyNum, DeciPlace - 1))
End If
CountX = 1
Do While MyNum <> ""
Temp = GetHundreds(Right(MyNum, 3))
If Temp <> "" Then Dllr = Temp & Place(CountX) & Dllr
If Len(MyNum) > 3 Then
MyNum = Left(MyNum, Len(MyNum) - 3)
Else
MyNum = ""
End If
CountX = CountX + 1
Loop
Select Case Cts
Case ""
Cts = ""
Case "One"
Cts = " Point One "
Case Else
Cts = " Point " & Cts & " "
End Select
SpellNumberY = Dllr & Cts
End Function
Function GetHundreds(ByVal MyNum)
Dim Result As String
If Val(MyNum) = 0 Then Exit Function
MyNum = Right("000" & MyNum, 3)
If Mid(MyNum, 1, 1) <> "0" Then
Result = GetDigit(Mid(MyNum, 1, 1)) & " Hundred "
End If
If Mid(MyNum, 2, 1) <> "0" Then
Result = Result & GetTens(Mid(MyNum, 2))
Else
Result = Result & GetDigit(Mid(MyNum, 3))
End If
GetHundreds = Result
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 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``````
• Then, close the Visual Basic window.
• After that, select the cell where you want to use the spell number function.
• Then, write down the following formula.
`=SpellNumberY(B5)` • Press Enter to apply the formula. • Then, drag the Fill Handle icon down the column. 🔎 VBA Code Explanation:

``````Option Explicit
Function SpellNumberY(ByVal MyNum)``````

First of all, define the function name and also define the value of the function.

``````Dim Dllr, Cts, Temp
Dim DeciPlace, CountX
ReDim Place(9) As String
Place(2) = " Thousand "
Place(3) = " Million "
Place(4) = " Billion "
Place(5) = " Trillion "``````

Next, declare the necessary variable for the macro. The String is a representation of the amount.

``MyNum = Trim(Str(MyNum))``

Next, we trim the string value’s extra space.

``DeciPlace = InStr(MyNum, ".")``

After that, use the InStr function to find out the position of the sub-string within a string and set the position of the decimal place as 0 if none.

``````If DeciPlace > 0 Then
Cts = GetDigit(Left(Mid(MyNum, DeciPlace + 1) & _
"00", 1)) & " " & GetDigit(Left(Mid(MyNum, DeciPlace + 2) & _
"00", 1))
MyNum = Trim(Left(MyNum, DeciPlace - 1))
End If
CountX = 1``````

Then, if the decimal place is greater than zero. Convert Cents and set Numbers to the dollar amount. If the criteria match then, set the countX as 1.

``````Do While MyNum <> ""
Temp = GetHundreds(Right(MyNum, 3))
If Temp <> "" Then Dllr = Temp & Place(CountX) & Dllr
If Len(MyNum) > 3 Then
MyNum = Left(MyNum, Len(MyNum) - 3)
Else
MyNum = ""
End If
CountX = CountX + 1
Loop``````

Next, use the Do while loop, if the number is not blank.  Then, check if the temp is not blank. After that, define the dollar. Again check if the number is greater than 3 then, define the number value. Otherwise, it will return a blank. If the loop works, then, add the 1 to the previous countX and finish the loop.

``````Select Case Cts
Case ""
Cts = ""
Case "One"
Cts = " Point One "
Case Else
Cts = " Point " & Cts & " "
End Select``````

For the cents case, if the case is blank, then it will return cents as blank. For case one, it returns cents as point one. Otherwise, it will return the cents amounts.

``````SpellNumberY = Dllr & Cts
End Function``````

Finally, when you use the spell function and define the numbered cell, it will return the value of both dollars and cents.

``Function GetHundreds(ByVal MyNum)``

To Convert a number from 100-999 into text, define the function of the macro.

``Dim Result As String``

Next, declare the necessary variable for the macro.

``````If Val(MyNum) = 0 Then Exit Function
MyNum = Right("000" & MyNum, 3)``````

If the val function returns a zero number from the string, then the function will end.

``````If Mid(MyNum, 1, 1) <> "0" Then
Result = GetDigit(Mid(MyNum, 1, 1)) & " Hundred "
End If``````

The mid function returns a specific number of characters from the string. Here, the mid function extracts the first character. If this is not equal to zero or not. Then, define the result to convert the hundreds place.

``````  If Mid(MyNum, 2, 1) <> "0" Then
Result = Result & GetTens(Mid(MyNum, 2))
Else
Result = Result & GetDigit(Mid(MyNum, 3))
End If``````

Then, take the mid function and it starts from 2nd place and finishes after one character. Now, check if that is not equal to zero or not. Then, define the result with GetTens to convert the tens place. Otherwise, it takes results using GetDigit to convert the one’s place.

``````GetHundreds = Result
End Function``````

Next, the GetHundreds take the result. After that, ends the function.

``Function GetTens(TensText)``

To convert a number from 10 to 99 into text, define the function of the macro.

``Dim Result As String``

Next, declare the necessary variable for the macro.

``Result = ""``

Define the result as null out of the temporary function value

``````  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``````

Next, set the if condition. First, the left function returns the first character from the tensText. After that, Val function takes that return value and returns the number that is contained in that string. Finally, check if the number is equal to 1. If it meets the criterion, then, returns the defined case result. Finally, end the process.

``````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``````

Otherwise, If the value is between 20-99, It also goes to the case using the val and left function. Then, returns the defined case result. Finally, end the process.

``````Result = Result & GetDigit _
(Right(TensText, 1))
End If
GetTens = Result
End Function``````

Then, define the result with GetDigit. Next, using the Right function retrieves the one’s place. Finally, end the function.

``Function GetDigit(Digit)``

To convert a number from 1 to 9 into text. Define the GetDigit function of the macro.

``````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``````

Then, select the case using the Val function. It returns numbers that are contained in a string. Then, check which case is applicable for that. Otherwise, returns as blank. Then, end the selection.

``End Function``

Finally, end the function of the macro

Read More: How to Spell Number in Taka in Excel

## Conclusion

We have shown two different examples to use the spell number in Excel including with currency and without currency. Both of the examples provide a complete guideline on how to use the spell number in Excel. I hope we covered all possible areas on this topic. If you have any more questions, feel free to ask in the comment box.

## What is ExcelDemy?

ExcelDemy Learn Excel & Excel Solutions Center provides free Excel tutorials, free support , online Excel training and Excel consultancy services for Excel professionals and businesses. Feel free to contact us with your Excel projects. Durjoy Paul

Hi there! I'm Durjoy. I have completed my graduation from the Bangladesh University of Engineering and Technology. I am working and doing research on Microsoft Excel and here I will be posting articles related to it.

1. Reply Sandeep Bhattacharjee May 27, 2023 at 1:47 PM

Its a wonderful experience. I am not any master or professional, I just practice excel at home. The Codes provided in the website of exceldemy.com really works without any difficulties or confusion. I am really happy and wish that I will be able to learn a lot from this website. Thank you and hope that you will continue to help us in learning.

• Reply Shamima Sultana May 28, 2023 at 10:49 AM

Dear Sandeep Bhattacharjee,

You are most welcome and thanks for your appreciation.

Regards
ExcelDemy

2. Reply i am Trying this and its work but if we close excel and opne again than this formula not work

• Reply Osman Goni Ridwan Oct 4, 2023 at 12:05 PM

Hello Ankit,
Thanks for sharing your problem. The file is working completely fine from our end. So, if you think your Excel VBA function is not working after saving and reopening the workbook, there could be several reasons for this issue. Here are some common troubleshooting steps to help you resolve the problem:

1. Check for Macro Security Settings:
>> Excel has a security feature that may disable macros by default.
>> Make sure that macros are enabled in your Excel settings.
>> Go to “File” > “Options” > “Trust Center” > “Trust Center Settings.” Under “Macro Settings,” select “Enable all macros” or “Enable macros for this session” to allow macros to run.

2. Check Workbook FIle Extension
Check if the VBA code is stored in a macro-enabled workbook (with the .xlsm file extension) rather than a regular .xlsx workbook. Macros won’t run in regular Excel workbooks.

3. Check Event Triggers:
Check that we have used the code associated with each worksheet. Make sure that these events are still properly associated with the worksheets in your file.

I believe by following these steps, you should be able to identify and resolve the issue. Please inform us of the outcome in a reply. Thanks for staying with us! Advanced Excel Exercises with Solutions PDF  