VBA & Macro Problems

Fix the Excel #NAME? Error for a VBA User-Defined Function

Algirdas JasaitisAlgirdas Jasaitis Nov 25, 2026 870 views

Question details

Fix an Excel #NAME? error when a worksheet formula calls a VBA user-defined function.

Fix the Excel #NAME? Error for a VBA User-Defined Function
Product
Microsoft Excel
Device & OS
not provided
Scenario
A worksheet formula needs to call a VBA function, including a function with no arguments.
Observed behavior
Excel displays #NAME? when the function is called incorrectly or is unavailable to the worksheet.
Before you start

Open the workbook in a desktop version of Excel that supports VBA. Identify the function name in the formula and make sure the workbook or add-in containing its code is available.

Solution 1Recommended

Check the VBA function call and make it available to Excel

Use these checks when Excel displays #NAME? instead of recognizing a VBA function in a worksheet formula.

1
Correct the formula

Select the cell showing #NAME? and check the function name and parentheses in the formula bar. For a function with no arguments, enter =bScoresAreEntered() or =IF(bScoresAreEntered(),1,2).

2
Check the function declaration

Open the Visual Basic Editor from Developer > Visual Basic. In the project containing the function, confirm that it is declared Public, for example, Public Function bScoresAreEntered().

3
Use a standard module

In the Visual Basic Editor, check that the function is in a standard module under Modules, rather than in a worksheet or ThisWorkbook code module. If needed, choose Insert > Module and move the function there.

4
Save in a macro-enabled format

If the function is stored in the workbook, choose File > Save As and select Excel Macro-Enabled Workbook (*.xlsm) as the file type.

5
Enable trusted macros

Reopen the workbook and, if Excel displays a security warning, select Enable Content only if you trust the file and its source. Then select the formula cell and press Enter to recalculate it.

Check the VBA function call and make it available to Excel
Check the function source: If the function is stored in a separate workbook or add-in, that source must also be available to Excel.
Free Microsoft Office alternative

Work with Excel spreadsheets in WPS Office

WPS Office is a free, lightweight Office alternative with a familiar interface and support for common Excel formats, making it easy to move everyday spreadsheet work from Microsoft Office. VBA compatibility can vary, so test macro-dependent workbooks before switching.

Open and edit spreadsheets in a familiar interfaceSupports common Microsoft Excel formats, including XLSX and XLSReview formulas and spreadsheet data in WPS SpreadsheetsFree and lightweight for everyday Office tasks
microsoft office alternative - wps office

Frequently Asked Questions

Why does my VBA function need parentheses in an Excel formula?

Parentheses identify the function call, even when it takes no arguments. In the formula bar, use =bScoresAreEntered() rather than leaving off the parentheses.

Where should I put a VBA function used by a worksheet?

In Developer > Visual Basic, place the Public function in a standard module under Modules. Choose Insert > Module if you need to create one.

Can I save a workbook with a VBA function as an XLSX file?

The XLSX format does not retain VBA code. Use File > Save As and select Excel Macro-Enabled Workbook (*.xlsm) when the function is stored in the workbook.

What should I do if Excel blocks the workbook's macros?

If a security warning appears when you open the workbook, select Enable Content only when you trust the file and its source. The VBA function cannot run if its macros remain blocked.