Indirectly Referencing a Cell on a Different Worksheet

by Allen Wyatt
(last updated July 3, 2018)

9

Michael has a worksheet that has month names (January, February, etc.) in column A. In column B he wants to pull a value from cell B11 of whatever worksheet is specified in column A. Thus, if column A contains the month "March," in the cell just to the right of March (in column B) he wants to pull the value in March!B11. Michael believes that the INDIRECT function should help with this, but he can't get it to work.

The good news is that Michael is correct—you can use the INDIRECT function to do this. The basic usage of the function looks like this:

=INDIRECT(A1&"!B11")

You can build a more "robust" version of the formula by enclosing it within a function that checks for errors. If there is an error, then the phrase "No Data" displays in the cell:

=IFERROR(INDIRECT(A1&"!B11"),"No Data")

These approaches use whatever is in cell A1 directly, which works provided that the value in A1 is text and a single word. If there might be a second word in A1 (such as "July Production"), then you need to modify the formula a bit so that it includes apostrophes around whatever is in cell A11:

=IFERROR(INDIRECT("'"&A1&"'!B11"),"No Data")

Because the apostrophes are used to enclose a worksheet name, you cannot have any text in cell A1 that includes apostrophes. So, "July Production" in cell A1 will work fine (provided you have a worksheet named "July Production"), but "July's Production" will not work because of the apostrophe.

Further, if whatever is in cell A1 may have either leading or trailing spaces on it, then you'll need to get rid of those spaces. The easiest way to compensate is to use the TRIM function:

=IFERROR(INDIRECT("'"&TRIM(A1)&"'!B11"),"No Data")

All of the variations presented so far work just fine if the value in A1 is an actual string. They won't work if the value in A1 is an actual date, formatted to look like a month name. Dates are stored internally as numbers, and using one of the formulas discussed so far will try to add the date serial number to the cell reference, which generates an error. Instead, you need to use the TEXT function to convert the date in A1 to a month name:

=IFERROR(INDIRECT(TEXT(A1,"mmmm")&"!B11"),"No Data")

If you are expecting other people to enter month names into cell A1, then you would be well advised to make that entry as fool-proof as possible. The best way to do that is to use data validation to limit what can be entered into cell A1. (How you use data validation has been covered in other issues of ExcelTips.)

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (12701) applies to Microsoft Excel 2007, 2010, 2013, and 2016.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Sorting a Range of Cells

When you sort data in a worksheet, you don't need to sort everything at once. You can sort just a portion of your data by ...

Discover More

Turning Off Automatic Hyphenation for Parts of a Document

Word can hyphenate documents automatically, if you want it to. But what about those situations where you want most of a ...

Discover More

Storing Sorting Criteria

Need to do the same sorting operation over and over again? Excel doesn't provide a way to save your sorting criteria, but ...

Discover More

Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!

More ExcelTips (ribbon)

Hiding Rows Based on Two Values

It's easy to use filtering to hide rows based on the value in a cell, but how do you hide rows based on the values in two ...

Discover More

Dealing with Circular References

Circular references occur when a formula includes a reference to the cell in which the formula appears. Here's how you ...

Discover More

Counting Names Based on Two Criteria

Need to figure out how many rows in a worksheet meet two criteria that you specify? Here's how to get the info you desire.

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 9 + 2?

2018-03-30 05:13:54

Michael (Micky) Avidan

@JN,
A slight change will solve your problem.

=IFERROR(INDIRECT(TEXT(A3,"MMDD")&LEFT(B2,1)&"!B6"),"")

*** Pay attention to the parenthesize location change ***
----------------------------
Michael (Micky) Avidan
“Microsoft® Answers" - Wiki author & Forums Moderator
“Microsoft®” Excel MVP – Excel (2009-2018)
ISRAEL


2018-03-29 14:13:05

JN

I have a file where I receive reconciliations from cashiers for total money they received by day by tender type. I keep them all together in a workbook by month and have a summary tab. I name each tab MMDDx where x is the first initial of the cashier. For example, Ann's March 1st receipt tab is labeled 0301A. I setup this formula on my summary tab to pull the numbers from certain cells in each tab:

=IFERROR(INDIRECT(TEXT(A3,"MMDD"&LEFT(B2,1))&"!$b$6"),"")

B2 is the name of the cashier, A3 is the date. So this formula joins the date (in cell A3) and the first initial of the cashier (from cell B2) and returns the value of cell B6 on that tab. I have found that this only works with certain letters. If I have a cashier whose name starts with B, D, E, G, H, M, N, S, or Y the formula will not work. Any ideas why this wouldn't work on certain letters? Thanks!


2018-03-29 11:59:35

JN

I have a file where I receive reconciliations from cashiers for total money they received by day by tender type. I keep them all together in a workbook by month and have a summary tab. I name each tab MMDDx where x is the first initial of the cashier. For example, Ann's March 1st receipt tab is labeled 0301A. I setup this formula on my summary tab to pull the numbers from certain cells in each tab:

=IFERROR(INDIRECT(TEXT(A3,"MMDD"&LEFT(B2,1))&"!$b$6"),"")

B2 is the name of the cashier, A3 is the date. So this formula joins the date (in cell A3) and the first initial of the cashier (from cell B2) and returns the value of cell B6 on that tab. I have found that this only works with certain letters. If I have a cashier whose name starts with B, D, E, G, H, M, N, S, or Y the formula will not work. Any ideas why this wouldn't work on certain letters? Thanks!


2018-02-23 10:34:39

Dave Bonin

One more add on INDIRECT...

It becomes even more powerful when combined with the ADDRESS() function, such as:

= INDIRECT( "'[WorkbookName.xlsx]" & SheetName & "'!" & ADDRESS( CellWithRowNumber, AnotherCellWithColumnNumber ))

= INDIRECT( "'[WorkbookName.xlsx]SheetName'!" & ADDRESS( CellWithRowNumber, AnotherCellWithColumnNumber ))

= INDIRECT( "'[WorkbookName.xlsx]SheetName'!B" & CellWithColumnNumber )

Getting the workbook name and sheet name is always kind of a pain, but there's a beautiful shortcut. Start your formula with:

= INDIRECT(

...and then click any cell of the sheet you want to reference. Let's say it happens to be B4 for this example. This is what you'll have:

= INDIRECT( '[WorkbookName.xlsx]SheetName'!B4" )

From here it's an easy end by enclosing the workbook and sheet name in double quotes and stripping off the cell address:

= INDIRECT( "'[WorkbookName.xlsx]SheetName'!" )

Then finish it off by adding an appropriate cell reference:

= INDIRECT( "'[WorkbookName.xlsx]SheetName'!" & ADDRESS( CellWithRowNumber, AnotherCellWithColumnNumber ))

While this looks complicated, take a deep breath and break it down into a few, easy steps. There's really not that much there there.

The hardest part is coming up with the values for the

...ADDRESS( CellWithRowNumber, AnotherCellWithColumnNumber )) portion.

I often add values in helper cells and then have ADDRESS() reference those cells. Many times these helper values contain a series of consecutive numbers, like 4, 5, 6, 7... or sequential numbers with a break, say, every three cells, like 4, 5, 6, 8, 9, 10, 12...

Or I'll have arguments like:

ADDRESS( ROW() + 2, COLUMN() + 3 )

I use this when the pattern of the cells I'm copying matches the pattern of cells I'm pasting to, it's just shifted over a few rows and columns.

So, why don't I just do a copy and paste?

1) Because I sometimes am copying from multiple sheets to multiple sheets.

2) Because I'm often working with non-contiguous cells -- different blocks or every other row.

3) Because I can select a dozen sheets and write the same formula on each simultaneously.


2018-02-22 10:53:46

Dave Bonin

The INDIRECT() function is extremely powerful when pulling data from multiple data sources.

For example, I have a monthly report workbook with about a dozen sheets corresponding to
different plants and divisions. It's data comes from over a dozen different files, by different
providers, each pulling their data from different sources, and provided in different formats,
some of which are ad-hoc or which evolve each month. (I work for a very large division of a
very large company.)

Mastering the INDIRECT() function allowed me to reduce my data transfer time by up to 90%
or more and greatly reduce errors. With practice, one can quickly and easily write functions
to transfer a hundred cells from a dozen sheets of one workbook to a dozen sheets of another
workbook all at once even if their arrangements are different.

I really can't say enough good things about INDIRECT(), particularly when full automation is not
a good option.


2013-11-08 01:29:15

Shreepad S M Gandhi

It can be said based on my experience of using the INDIRECT function that if you have your data in a horizontal matrix (i.e in various columns under their headers), but need to extract them in a vertical matrix (i.e headings placed in rows one below the other) then INDIRECT is an excellent functionality provided by Excel. Please mail me on shreepadg@gmail.com, if anyone wishes to see a demo workbook/tutorial.


2013-11-04 13:32:28

Bryan

This is a good introduction on one way to use the INDIRECT function. However, it should be mentioned that most (if not all) uses of INDIRECT can and should be avoided. There are a few reasons for this.

(1) INDIRECT is a volatile function. This means that Excel will recalculate any cell with an INDIRECT every time ANY cell on the sheet is updated. Extensive use of INDIRECTs can slow down your calculation time dramatically.

(2) Much of the time if you need to use an INDIRECT, you have poorly structured data. The imaginary workbook used in this tip is a prime example: you should never separate monthly data by worksheet. What happens at the end of the year? How do you do an aggregate across months? How do you compare one month to the next? What if you figure out you had been entering data into the wrong month? If you use a structured data format with one table containing a "date" column, you will have no problems manipulating the data down the line. Once your data is structured, you will almost always eliminate the need to use an INDIRECT formula, and you can use something like INDEX/MATCH , VLOOKUP or SUMPRODUCT – all of which are non-volatile functions.


2013-11-04 09:31:16

Adam

This will work, but only if the workbook is open.


2013-11-02 11:21:45

Linda W

Will this work referencing another workbook?


This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.