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

by Allen Wyatt
(last updated July 13, 2015)

6

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

Default Units that Change

Word allows you to specify the unit of measurement you would like used in dialog boxes throughout the program. It can get ...

Discover More

Selecting a Word

Selecting text is a critical skill to possess when you want to work with a Word document. This tip explains how you can ...

Discover More

Inserting a Sound File in Your Document

Got an audio file you want to insert in your document? It's easy to do when you use the Object dialog box, as described in ...

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)

Weighted Averages in a PivotTable

PivotTables are used to boil down huge data sets into something you can more easily understand. They are very good simple ...

Discover More

Rows in a PivotTable

PivotTables are used to analyze huge amounts of data. The number of rows used in a PivotTable depends on the type of analysis ...

Discover More

Setting Stable Column Widths in a PivotTable

When you update a PivotTable, Excel can take liberties with any formatting you previously applied to the PivotTable. Here's ...

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 for this tip:

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. 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 7 + 8?

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.


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.

Links and Sharing
Share