How to Dynamically Reference Excel Worksheets by Date and Workbook
Question details
The user needs to retrieve data from multiple external workbooks where the worksheet names represent dates, dynamically matching a specific date selected in the primary workbook.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Consolidating or looking up data across multiple external workbooks that organize data into daily date-named worksheets.
- Observed behavior
- The user wants to set up a dynamic reference system that automatically constructs the file path and fetches data from the correct worksheet based on a selected date cell.
Ensure all target workbooks follow a strict, consistent naming convention for their date-based worksheets (e.g., 'YYYY-MM-DD') and store them in a single accessible folder or SharePoint location.
Use Power Query and XLOOKUP for Reliable Multi-Workbook Referencing
Power Query is the most robust method for pulling data from closed workbooks. It consolidates the date sheets into a helper table, which you can then dynamically query using XLOOKUP.
This method avoids the common #REF! error associated with closed workbooks by establishing a permanent data connection to your source folder.
Place all the target workbooks (Workbooks 2 through 6) containing the date-named worksheets into a single, dedicated folder on your computer or a SharePoint location.
In your main workbook, navigate to Data > Get Data > From File > From Folder. Select your dedicated folder and click 'Transform Data'.
Filter the files if necessary, then click the 'Combine Files' button on the Content column. Expand the data to combine the date-named worksheets into one comprehensive dataset.
Once the data is transformed and includes the date column (derived from the worksheet names), click 'Close & Load To...' and place it in a new helper sheet in your main workbook.
In your main reporting sheet, use the XLOOKUP function to search the combined helper sheet for the specific date selected in your cell, returning the corresponding data values.

Use the INDIRECT Function for Dynamic References
The INDIRECT function allows you to build a cell reference as a text string. This is faster to set up but requires all referenced source workbooks to be open.
Efficiently Consolidate Data Across Sheets with WPS Spreadsheet
WPS Office provides powerful data consolidation and lookup features, allowing you to easily manage and analyze data across multiple workbooks and date-based sheets without heavy resource consumption.
- 1. Open WPS Spreadsheet: Launch WPS Office and open your main workbook in the Spreadsheet application.
- 2. Use Lookup Functions: Utilize the built-in XLOOKUP or INDIRECT functions directly in the formula bar to link your date-based worksheets.
- 3. Consolidate Data: Navigate to the Data tab and use the 'Consolidate' feature to merge data from multiple open workbooks quickly.
- 4. Save in Standard Formats: Save your consolidated reports in standard .xlsx format, ensuring perfect compatibility with other spreadsheet software.

Frequently Asked Questions
Why does my INDIRECT formula return a #REF! error?
This happens if the target external workbook is closed. The INDIRECT function requires all referenced source workbooks to be actively open in the background to evaluate the cell reference correctly. If you need to read closed workbooks, Power Query is the better alternative.
Can I use VLOOKUP instead of XLOOKUP to find data by date?
Yes, you can use VLOOKUP on your combined helper sheet. However, XLOOKUP is generally recommended because it handles exact matches by default, allows you to search in any direction, and handles missing data without returning standard #N/A errors.
How do I format a date to exactly match a worksheet name?
You can use the TEXT function to convert a raw date value into a formatted string that matches your sheet name. For example, if your date in cell A1 is October 5, 2023, and your sheet is named '2023-10-05', use the formula =TEXT(A1, "yyyy-mm-dd") inside your reference.




