Excel dynamic array formulas (FILTER, UNIQUE, SORT) referencing a closed external workbook will fail and throw a #REF! error. This happens because the calculation engine requires the source file to be physically open to determine the dimensions of the final spill range.
To fix this, you must stop linking directly to the external workbook. Instead, reroute the data through a Power Query connection to create a local, cached table:
- In your master workbook, go to Data > Get Data > From File > From Workbook.
- Select your closed source file, select the data sheet, and click Load.
- Excel will import the data into a new, green structured Table (e.g.,
Table1). - Point your dynamic array formula at this new local table:
Excel
=FILTER(Table1, Table1[Region]="North", "No matching records")
Power Query materializes the external data inside your current workbook. The spill engine now reads from Table1, where all dimensions are immediately accessible, completely bypassing the closed workbook restriction.
Prerequisites
- Excel 365 or Excel 2021: Power Query’s workbook connector and the dynamic array spill engine must both be present. Excel Online does not support importing from local file paths.
- Read Access: The account running Excel must have filesystem read permissions to the absolute path of the source file (e.g.,
C:\Reports\SourceData.xlsxor a shared network drive).
The Syntax Breakdown
When you use the UI buttons to load the data, Excel automatically generates the Power Query “M” language script in the background. Here is exactly what that script is doing:
File.Contents("Path")— Reads the raw binary content of the target file from the filesystem. This step executes flawlessly even if Excel does not have the file open.Excel.Workbook(..., null, true)— Parses the binary blob as a workbook object. Thetrueargument delays type inferencing, preventing the connector from corrupting ambiguous text/number columns.Table.PromoteHeaders(...)— Elevates the first data row to become the Table’s column headers.Table.TransformColumnTypes(...)— Explicitly locks in the data types (Text, Number, Date). This prevents yourFILTERcomparison operators from failing silently on mixed-type columns.Table1[Region]="North"— The structured Table reference in your new formula. Using column names instead of cell ranges (likeA2:A100) makes the formula completely immune to breaking if columns are inserted or deleted in the source file.
Real-World Example: Overnight Dashboard Refreshes
A financial analyst maintains a master dashboard aggregating data from regional budget workbooks stored on a network drive. The FILTER formulas work perfectly during business hours when the analysts have the source files open on their screens.
At 2:00 AM, a Task Scheduler macro triggers an automated dashboard refresh—but the source files are closed. The next morning, 400+ cells display #REF! across the dashboard.
The analyst replaces the direct external references with a Power Query connection, loading the data into a local table named tbl_SourceData.
The Broken Formula (Direct Link):
=FILTER('C:\Reports\[SourceData.xlsx]Sheet1'!A2:D100, ...) -> Returns #REF!
The Fixed Formula (Power Query Link):
Excel
=FILTER(
tbl_SourceData[[Order ID]:[Revenue]],
tbl_SourceData[Region]="North",
"No matching records"
)
Output Table (Spills correctly regardless of source state):
| Order ID | Region | Product | Revenue |
| ORD-1001 | North | Widget A | 48,200 |
| ORD-1003 | North | Widget C | 62,800 |
| ORD-1005 | North | Widget B | 55,100 |
The overnight refresh now completes cleanly. Power Query refreshes the local tables from the closed files in the background, and FILTER spills against that in-memory data effortlessly.
Common Related Errors & Fixes
- Power Query Data Becomes Stale -> Cause: Power Query does not auto-refresh on file open by default. The local table holds a static snapshot from your last manual refresh. -> Fix: Enable automatic refresh. Go to Data > Queries & Connections. Right-click your query, select Properties, and check the box for “Refresh data when opening the file.”
- #SPILL! Error After a Refresh -> Cause: The
FILTERformula worked initially, but after a Power Query refresh added 50 new rows to the source file, the spill area collided with text sitting below the formula. -> Fix: Never place any text or totals directly beneath a dynamic array formula. Move your aggregation formulas above the headers, leaving the rows below completely empty.
Key Takeaways
- The core fix is materialization, not reformulation. You must route the external data through Power Query to give the engine a fully resident, open Table to interrogate.
- Ensure you configure your Power Query connection to refresh automatically on open, otherwise, your dashboard will display stale data.
- This approach is actually faster at steady-state than keeping source workbooks open, as the dynamic arrays calculate instantly against local memory.
Frequently Asked Questions
Can INDEX/MATCH reference a closed workbook where FILTER cannot?
Yes. Legacy lookup functions like INDEX/MATCH and VLOOKUP return a single scalar value per formula cell. The engine does not need to negotiate spill range dimensions against the source; it just requests one cached value from the closed workbook’s link table.
Does this fix work if the source file is in SharePoint?
Yes, but you cannot use the standard “From File” button. Go to Get Data > From File > From SharePoint Folder. Using a local file path to a SharePoint-synced folder is unreliable across different machines. The SharePoint connector handles Microsoft 365 authentication natively in the cloud.
Do I need to format the source data as an Excel Table first?
Formatting the source data as an official Excel Table makes Power Query much more resilient to blank rows, extra whitespace, and layout changes above the data range. It also eliminates the need to manually promote headers in the query editor.