Please Note: This article is written for users of the following Microsoft Excel versions: 2007 and 2010. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Error in Linked PivotTable Value.

Error in Linked PivotTable Value

Written by Allen Wyatt (last updated November 2, 2022)
This tip applies to Excel 2007 and 2010


8

Adam has two workbooks; call them A and B. In workbook A he has a link to a value in a PivotTable that is in workbook B. When he opens workbook A and workbook B is not open, Adam gets a #REF! error for the link. He wonders if there is any way to avoid getting the error when linking to a PivotTable value in a workbook that is not open.

There are a couple of ways you can approach this problem. Both methods involve understanding how Excel references the PivotTable value in workbook A. When you create a link to the value and both workbook A and workbook B are open, the reference will look something like this:

=GETPIVOTDATA("TotalValue",'C:\XLDocs\[MyData.xls]PTable'!$H$15,"EName","Rac")

One way to handle the problem is to envelope the reference within an IF statement, in this manner:

=IF(ISERROR(=GETPIVOTDATA("TotalValue",'C:\XLDocs\[MyData.xls]PTable'!
$H$15,"EName","Rac")),"Make sure Workbook B is Open", =GETPIVOTDATA(
"TotalValue",'C:\XLDocs\[MyData.xls]PTable'!$H$15,"EName","Rac"))

The formula checks the result of the GETPIVOTDATA function, and if it returns an error value (like when workbook B is not open), it displays a message. Only if there is no error value will the value in workbook B be fetched.

Another way is to modify the original reference so that the GETPIVOTDATA function is not being used. (It is this particular function that is generating the error when workbook B is not open.) Here's the way you should redo the reference so that the value is referenced directly instead of through a function:

='C:\MyWork\XLDocs\[MyData.xls]PTable'!$H$15

When the reference is rewritten in this manner, the error condition isn't returned.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (10650) applies to Microsoft Excel 2007 and 2010. You can find a version of this tip for the older menu interface of Excel here: Error in Linked PivotTable Value.

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

Limits on Path Length in Word

When you organize your hard drive, it is easy to go hog-wild with folders and subfolders. You need to know that how you ...

Discover More

Removing Confusion When Using AutoCorrect

AutoCorrect is a great help when writing, as it can allow you to create regular blocks of text easily. This can cause ...

Discover More

Generating a Unique ID Number

If you are keeping track of people or things within Excel, you may want to devise unique ID numbers you can use for those ...

Discover More

Excel Smarts for Beginners! Featuring the friendly and trusted For Dummies style, this popular guide shows beginners how to get up and running with Excel while also helping more experienced users get comfortable with the newest features. Check out Excel 2013 For Dummies today!

More ExcelTips (ribbon)

Empty PivotTable Cells Don't Show as Blank

You can configure Excel so that it displays special text within blank PivotTable cells. Here's how to make the changes ...

Discover More

Default Formatting for PivotTables

Wish there was a way to define how you want PivotTables formatted before you actually create the PivotTable? You may be ...

Discover More

Using Classic PivotTable Layout as the Default

Are you attached to the classic PivotTable layout? Looking for a way to make that layout the default for new PivotTables? ...

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}] (all 7 characters, in the sequence shown) 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 2 + 2?

2023-10-12 20:06:44

Debbie Cavanagh

I'm not that familiar with excel and pivot tables. I am using a template to assist met. I have entered in my data on a worksheet, created the pivot table then pasted it into a different worksheet in the same document. When I do this I get the #REF! error code. Clicking on it shows me the formula but I do not understand the formula. I don't know what I've done wrong. The pivot table I am pasting over the top of the original is the same size as the original.


2019-01-02 13:02:02

David Gray

I would rewrite the formula like so:

=IFERROR(GETPIVOTDATA("TotalValue",'C:\XLDocs\[MyData.xls]PTable'!$H$15,"EName","Rac"),"Make sure Workbook C:\XLDocs\[MyData.xls is Open")

Not only is this simplified by eliminating the duplicate external reference, but the error message identifies the other worksheet by name.


2015-01-12 01:01:31

Banzoey

I agree with Col's approach - iferror() instead of if(iserror()) and this should also help address Kathy's query. It is cleaner, easier to read and easier to edit or modify at a later stage.
The only problem with any of these approaches is that you get a #REF! error in the case that the workbook with the pivot table is closed (which will then be replaced with "Open workbook B" in the example). Unfortunately you get the same error if you try to reference an invalid value from the pivot table as well (e.g. no RAC in Ename as per above example), making it difficult to determine if you are referencing something that is not there or just not open.

Any suggestions on how to distinguish between these two?


2015-01-09 17:34:41

lib

You also get ref errors when you have a complex link to a closed file eg sumifs, index or array formula in link. Does anyone have a solution for this?
Because pivots can change, I link with an index or other lookup. Excel needs the file open for this


2015-01-09 09:43:32

Col Delane

If using Excel 2007 or later, for the first method it is far better (shorter, cleaner, faster) to use:
=IFERROR( GETPIVOTDATA("TotalValue",'C:XLDocs[MyData.xls]PTable'!$H$15, "EName","Rac"),"Make sure Workbook B is Open")
than
=IF(ISERROR( =GETPIVOTDATA("TotalValue", 'C:XLDocs[MyData.xls]PTable'!$H$15,"EName","Rac")),"Make sure Workbook B is Open", =GETPIVOTDATA(
"TotalValue",'C:XLDocs[MyData.xls]PTable'!$H$15,"EName","Rac"))

If Workbook B is open - being the desired situation - the former formula only executes the GETPIVOTDATA call once, whereas the latter will execute it twice (once to test if B is open, and then a second time to return the result)!


2015-01-09 07:29:33

Paul Whitaker

Will the following overcome this problem ?

When you refer to a cell in a Pivot Table Excel defaults to the GETPIVOTDATA formula instead of a normal R1C1-style cell reference (e.g. =D5). This can be turned off to use normal cell referencing:

1) Click on any cell in the PivotTable. From PivotTable Tools click the Options tab;

2) In the PivotTable group, click the small arrow on the right side of the Options command. You will see a checkmark next to the 'Generate GetPivotData' option;

3) Click the 'Generate GetPivotData' to turn the option off.

Note:
a) This is a global setting that remains off for all PivotTables until you turn it on again.
b) If the Pivot Table layout changes the R1C1-style cell reference will not adjust


If this hint works I should credit this Tip to THEEXCELADDICT.COM site


2015-01-09 07:23:48

balthamossa2b

Another solution is to change Calculation Mode to manual and refresh the Pivot Table when you want.

...Please don't do this. Really, it's annoying for everyone else involved.


2014-11-14 12:13:09

Kathy

Can I have a nested IF statement within a GETPIVOTDATA formula?

I'm trying to subtract two numeric fields within one pivot table and return either a positive or negative value....all done within one GETPIVOTDATA formula.

I have two separate GETPIVOTDATA formulas that each return the correct (positive or negative) results.

However I am unable to find a way to combine the logic into one =IF(GETPIVOTDATA... formula.


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.