Using GetPivotData and referncing a cell in another worksheet

jak82

Board Regular
Joined
Apr 28, 2016
Messages
146
Hi,

I am wanting to use getpivotdata to take the value from a pivot table for use in my main worksheet. I have managed to get that to work.

What I am struggling with is I was to be able to use a value in cell (C5) for the year YY ie 16 on the sheet that formula is on. I have tried to reference the cell in the formulae but seem to get #ref

Please find my code below... thanks :)

Code:
 =GETPIVOTDATA("journal_amount",'Pivot Table'!$A$3,"nlyear", 'P&L'!C5,"trans_period","01","account_code","1211")
 
Hi, welcome to the forum :)

What's in cell C5 - is it just the number 16 or is it a date formatted to show yy?

Can you also post the working formula when it does not reference C5?
 
Upvote 0
Hi Thanks Formr,

Just beginning my journey into the world of Excel.

Yes the value in C5 is just the number 16 I want to be abler to change to 15 etc to reference the value in the pivot table. The code that works is

Code:
 =GETPIVOTDATA("journal_amount",'Pivot Table'!$A$3,"nlyear","16","trans_period","01","account_code","1211")

Thanks
 
Upvote 0
Hi, it looks like the field in the pivot table is text - try this small alteration:

=GETPIVOTDATA("journal_amount",'Pivot Table'!$A$3,"nlyear", 'P&L'!C5&"","trans_period","01","account_code","1211")
 
Upvote 0
Works! Many Thanks for the help. Now to try and understand how it works.

It looks like you are referencing the sheet as a string then the cell separately and concatenating it with an empty string.
 
Upvote 0
Glad to help :)

We are referencing the cell in the normal way and concatenating it's value with an empty string. This coerces the returned value to a string instead of a number.
 
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top