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

Understanding Default DATE Field Formatting

The DATE field is one of the most commonly used fields for placing dynamic information in your document. It is helpful to ...

Discover More

Quickly Copying Worksheets

Excel provides a little-known way to copy worksheets simply by clicking and dragging. Here's how to do it.

Discover More

Creating Folders

Folders are an organizational tool that allow you to easily store like items in Drive. This tip examines how easy it is to ...

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)

Bogging Down with Calculated Items

Create a complex PivotTable and you may find that your system slows to a crawl. The reason for this may be due to the way in ...

Discover More

Reducing File Sizes for Workbooks with PivotTables

Need to reduce the size of your workbooks that contain PivotTables? Here's something you can try to minimize the ...

Discover More

Suppressing Zero Values in PivotTables

PivotTables are great for digesting and analyzing huge amounts of data. But what if you want part of that data excluded, such ...

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 2 + 1?

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.