Formula Errors

How to Use INDIRECT with Excel File Names Containing Spaces

Natalie TaylorNatalie Taylor Oct 22, 2026 869 views

Question details

The INDIRECT and XLOOKUP formulas return errors when referencing an external Excel workbook that has spaces in its file name.

How to Use INDIRECT with Excel File Names Containing Spaces
Product
Excel
Device & OS
not provided
Scenario
Dynamically referencing external workbooks with spaces in their file names using the INDIRECT and XLOOKUP functions.
Observed behavior
The formula fails and returns an error because of missing or incorrectly placed apostrophes around the workbook and worksheet string references.
Before you start

Ensure that the external Excel workbook you are referencing is currently open on your computer, as the INDIRECT function requires external files to be open to evaluate successfully without returning a #REF! error.

Solution 1Recommended

Properly Enclose the Workbook and Sheet Reference with Apostrophes

Fix the reference error by correctly placing apostrophes around the workbook and worksheet string inside your INDIRECT formula.

When an external workbook or worksheet name contains spaces, Excel requires the entire path to be enclosed in single quotation marks (apostrophes). If these are omitted or placed incorrectly within the INDIRECT string concatenation, Excel cannot parse the file path, causing the formula to fail.

1
Identify the external reference parts

Determine the exact name of your external workbook (e.g., test1 - Copy.xlsx) and the target worksheet.

2
Start the string with apostrophes

Build your INDIRECT text string starting with a double quote, followed by a single quote and an opening square bracket: "'[

3
Close the workbook reference

Add the workbook name, a closing square bracket, and a single quote immediately before the exclamation mark. For example: "'[test1 - Copy.xlsx]Sheet1'!"

4
Concatenate with dynamic cells

Combine the static strings with your dynamic cell references using ampersands (&). A complete XLOOKUP and INDIRECT formula should look like: =XLOOKUP($A5,INDIRECT("'[test1 - Copy.xlsx]"&$A$3&"'!$A:$A"),INDIRECT("'[test1 - Copy.xlsx]"&$A$3&"'!"&C$1))

5
Apply and verify

Press Enter to apply the formula. Make sure the external workbook is open in the background to allow INDIRECT to evaluate the reference and retrieve your data.

Properly Enclose the Workbook and Sheet Reference with Apostrophes
Keep External Files Open: The INDIRECT function cannot read data from a closed external workbook. If the referenced file is closed, the formula will return a #REF! error, even if your apostrophes are perfectly placed.
Resolve Formula Errors with WPS Spreadsheet

Use Advanced Formulas and Link External Workbooks Seamlessly in WPS Office

WPS Spreadsheet offers full compatibility with standard Excel functions, including INDIRECT and XLOOKUP. You can easily reference external workbooks and manage complex data lookups within a lightweight, highly compatible interface.

  1. 1. Open WPS Spreadsheet: Launch WPS Office and open both your main working spreadsheet and the external workbook you intend to reference.
  2. 2. Enter the formula: Select the cell where you want to perform the data lookup and start typing =INDIRECT(.
  3. 3. Add required syntax: Construct your string reference, ensuring you enclose the external workbook name in single quotes if it contains spaces (e.g., INDIRECT("'[Data File.xlsx]Sheet1'!A:A")).
  4. 4. Calculate and evaluate: Press Enter. WPS Spreadsheet will instantly calculate the formula and retrieve the correct data across the linked workbooks.
Fully compatible with Microsoft Excel .xlsx and .xls formats.Supports advanced lookup functions like XLOOKUP, VLOOKUP, and INDIRECT natively.Built-in formula error checking helps easily spot missing apostrophes and syntax issues.Lightweight software architecture ensures smooth performance even with multiple linked external workbooks open.
microsoft office alternative - wps office

Frequently Asked Questions

Why does my INDIRECT formula return a #REF! error with external links?

This typically happens for two reasons: the external workbook you are referencing is currently closed, or the syntax for the workbook name containing spaces is missing the required single quotation marks.

Can I use INDIRECT to reference a closed workbook?

No, the INDIRECT function only works with open external workbooks. If you need to pull data from a closed workbook, you must use direct cell links or alternative data extraction methods like Power Query.

Do I need single quotes around file names without spaces?

While not strictly required for file names without spaces, it is considered best practice to always include single quotes around external workbook and worksheet references. This prevents unexpected errors if the file or tab name is later changed to include a space.