Function Problems

How to Fix INDIRECT Formula Errors for Named Ranges with Spaces

Huma Ashraf ChHuma Ashraf Ch Nov 10, 2026 869 views

Question details

The user needs to fix an issue where the INDIRECT formula fails to retrieve data because the referenced cell contains spaces, while the actual named range uses underscores.

How to Fix INDIRECT Formula Errors for Named Ranges with Spaces
Product
Spreadsheet
Device & OS
not provided
Scenario
Setting up dependent drop-down lists or dynamic data validation where user-selected values contain spaces, but the corresponding named ranges must use underscores due to syntax rules.
Observed behavior
The INDIRECT function returns a #REF! error because the text string with spaces does not exactly match the defined named range.
Before you start

Verify that your named ranges have been successfully created using underscores in place of spaces (for example, 'Data_Set' instead of 'Data Set'), and locate the exact cell reference of your drop-down menu.

Solution 1Recommended

Use the SUBSTITUTE Function Inside INDIRECT

Wrap the cell reference with a SUBSTITUTE formula to automatically replace spaces with underscores before INDIRECT evaluates the text string.

Since named ranges cannot contain spaces, standard practice is to use underscores. By nesting the SUBSTITUTE function inside INDIRECT, the formula automatically translates spaces from your drop-down list into underscores, creating a perfect match with your named range.

1
Select the target cell

Click on the cell where you want to display the retrieved data or set up your dependent data validation list.

2
Enter the nested formula

Type the formula =INDIRECT(SUBSTITUTE(J18, " ", "_")). Replace 'J18' with the actual cell reference that contains the text with spaces.

3
Apply and test

Press Enter to apply the formula. Change the value in your drop-down menu to verify that the formula successfully pulls data from the correct named range without returning a #REF! error.

Formula Breakdown: The SUBSTITUTE portion searches cell J18 for a space (" ") and replaces it with an underscore ("_"). The INDIRECT function then uses that modified text string to locate the named range.
Enhance Your Data Management

Master Complex Formulas Easily with WPS Spreadsheet

WPS Spreadsheet makes it effortless to manage named ranges, resolve complex INDIRECT scenarios, and build dynamic drop-down lists with highly intuitive formula assistants.

  1. 1. Download and install: Get WPS Office for free from the official website and install it on your device.
  2. 2. Open your spreadsheet: Launch WPS Spreadsheet and open your existing file containing the drop-down lists.
  3. 3. Access the Name Manager: Go to the Formulas tab and click on Name Manager to review your underscore-separated named ranges.
  4. 4. Apply the formula: Use the formula bar to type =INDIRECT(SUBSTITUTE()) and leverage the intelligent prompts to correctly map your ranges.
Seamless format compatibility with Microsoft Excel (.xlsx) files and advanced formula syntax.Built-in Name Manager to easily create, edit, and audit named ranges.Free, lightweight software that processes large datasets and complex calculations quickly.Smart formula autocomplete to prevent syntax errors like missing parentheses or quotation marks.
microsoft office alternative - wps office

Frequently Asked Questions

Why do I get a #REF! error when using the INDIRECT function?

The #REF! error means that the text string evaluated by the INDIRECT function does not match any valid cell reference or defined named range. When working with drop-down lists, this is most commonly caused by having spaces in the drop-down selection while the named range uses underscores.

Can I include spaces when defining a named range in my spreadsheet?

No. Spreadsheet software rules prohibit the use of spaces and certain special characters in named ranges to avoid syntax conflicts within formulas. You must use underscores, periods, or camel case (e.g., SalesData) to separate words.

How do I handle drop-down values that contain multiple spaces?

The SUBSTITUTE function replaces all instances of a specified character by default. Using =INDIRECT(SUBSTITUTE(A1, " ", "_")) will replace every space in the cell with an underscore, so a three-word phrase like 'Very Highly Willing' correctly transforms into 'Very_Highly_Willing'.

Can I use SUBSTITUTE to replace characters other than spaces?

Yes. If your drop-down values contain dashes, ampersands, or other characters not allowed in named ranges, you can nest multiple SUBSTITUTE functions. For example, =INDIRECT(SUBSTITUTE(SUBSTITUTE(A1, "-", "_"), " ", "_")) will replace both dashes and spaces with underscores.