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.
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.
Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!
Need to reduce the size of your workbooks that contain PivotTables? Here's something you can try to minimize the ...
Discover MoreIf you ever try to edit a PivotTable and get an error that tells you that the "underlying data was not included," it can ...
Discover MoreChanging the data source PivotTables go to can be a bit tricky. This tip explains what can happen when you re-point your ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
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
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.
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.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2024 Sharon Parq Associates, Inc.
Comments