## Excel dynamic worksheet or workbook reference

Supposing you have data with the same format across multiple worksheets or workbooks and need to get data from these worksheets or workbooks dynamically into another sheet. The INDIRECT function can help you quickly get it done.

#### Reference cells in another worksheet dynamically

Supposing there are four worksheets containing different sales in quarters for four salesmen, and you want to create a summary worksheet to dynamically pull the quarter sales based on the corresponding salesman. To make it work, the below formula can help.

Generic formula

=INDIRECT("'"&sheet_name&"'!Cell to return data from")

1. As the below screenshot shown, firstly, you need to create the summary worksheet by entering the sheet names separately in different cells, then select a blank cell, copy the below formula into it and press the Enter key.

=INDIRECT("'"&B3&"'!C3")

Notes: In the code:

• B3 is the cell containing the sheet name you will pull data from;
• C3 is the cell address in the specific worksheet you will pull its data;
• To prevent returning the error value if either B5 (the sheet name cell) or C3 (the cell you will pull the data) is empty, please enclose the INDIRECT formula with an IF function displaying as below:
=IF(OR(B3="",C3=""),"",INDIRECT(\$B\$3&"!C3"))
• If there are no spaces in your sheet names, you can directly use this formula
=INDIRECT(B3&"!C3")

2. Then, drag its Fill Handle down to apply the formula to other cells. Now you have returned all sales of the first quarter from the specific worksheets.

3. Go ahead to pull all sales of other quarters as you need. And don’t forget to change the cell reference in the formula.

#### Reference cells in another workbook dynamically

This section is talking about dynamically referencing cells in another workbook in Excel.

Generic formula

=INDIRECT("'[" & Book name & "]" & Sheet name & "'!" & Cell address)

As the below screenshot shown, The data you want to return locating in column E of worksheet “Total sales” in a separate workbook named “SalesFile”. Please do as follows step by step to get it done.

1. Firstly, let’s fill in the workbook information (including the workbook name, worksheet name, and reference cells), which you will pull data based on this information into current workbook.

2. Select a blank cell, copy the below formula into it and press the Enter key.

=INDIRECT("'["&\$B\$3&"]"&\$C\$3&"'!"&D3)

Notes:

• B3 contains the workbook name where you want to extract the data from;
• C3 is the sheet name;
• D3 is the cell you will pull data from;
• The #REF! error value will return if the referenced workbook is closed;
• To avoid the #REF! error value, please enclose the INDIRECT formula with the IFERROR function as follows:
=IFERROR(INDIRECT("'["&\$B\$3&"]"&\$C\$3&"'!"&D3),"")

3. Then drag the Fill Handle down to apply the formula to other cells.

Tip: If you don’t want the return value turning to be error after closing the referenced workbook, you can directly specify the workbook name, worksheet name and the cell address in the formula as this:
=INDIRECT('[SalesFile.xlxs]Total sales'!E3,"")

#### Related function

The INDIRECT function
The Microsoft Excel INDIRECT function converts a text string to a valid reference.

### The Best Office Productivity Tools

#### Kutools for Excel - Helps You To Stand Out From Crowd

 Popular Features: Find/Highlight/Identify Duplicates   |  Delete Blank Rows   |  Combine Columns or Cells without Losing Data   |   Round without Formula ... Super Lookup: Multiple Criteria VLookup | Multiple Value VLookup |  VLookup Across Multi-Sheets |  Fuzzy Lookup... Advanced Drop-down List: Easy Drop Down List   |  Dependent Drop Down List   |  Multi-select Drop Down List .... Column Manager: Add a Specific Number of Columns   |   Move Columns   |   Unhide Columns   |   Compare Columns to Select Same & Different Cells ... Featured Features: Grid Focus   |  Design View   |   Big Formula Bar   |  Workbook & Sheet Manager   |  Resource Library (Auto Text)   |  Date Picker   |  Combine Worksheets   |  Encrypt/Decrypt Cells   |  Send Emails by List   |  Super Filter   |   Special Filter (filter bold/italic/strikethrough...) ... Top 15 Toolset:  12 Text Tools (Add Text, Remove Characters ...)   |   50+ Chart Types (Gantt Chart ...)   |   40+ Practical Formulas (Calculate age based on birthday ...)   |   19 Insertion Tools (Insert QR Code, Insert Picture from Path ...)   |   12 Conversion Tools (Numbers to Words, Currency Conversion ...)   |   7 Merge & Split Tools (Advanced Combine Rows, Split Cells ...)   |   Many More...

Kutools for Excel boasts over 300 features, ensuring that what you need is just a click away...

Supports Office/Excel 2007-2021 & newer, including 365   |   Available in 44 languages   |    Full-featured 30-day free trial.

#### Office Tab - Enable Tabbed Reading and Editing in Microsoft Office (include Excel)

• One second to switch between dozens of open documents!
• Reduce hundreds of mouse clicks for you every day, say goodbye to mouse hand.
• Increases your productivity by 50% when viewing and editing multiple documents.
• Brings Efficient Tabs to Office (include Excel), Just Like Chrome, Firefox, And New Internet Explorer.