Replacing Pivot table cache

dustdaniel

New Member
Joined
Sep 25, 2024
Messages
4
Office Version
  1. 365
Platform
  1. Windows
Hi Everyone,

A couple of years ago I found in a different forum, that you can change the cache ID from a pivot table, you just need 2 functions to do so and I need your help to find what these are.

The purpose is to change the source cache from one pivot table and replace it with the cache from another pivot table in the same excel file.

I remember you had to click on one pivot table, then open visual basic with ALT+F11 then CTRL+G and write someting like

?ActiveWorkbook.XXXXX

This would return the Cache # (1, 2, 3, 4, whatever) of the pivot table.

Next step would be to click on the pivot table I want to chance source and go back to Visual Basic and write the second fuction that I don't recall

ActiveWorkbook.XXXXX but at the end yo include the cache # from the previous consult since this would override the cache #

I hope this enough information, It's clear that I have very basic VBA knowledge, please help me getting these two pieces I'll make sure I won't loose them again!
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
You will need to have the right sheet active and put in your pivot table name
? ActiveSheet.PivotTables("PivotTable6").CacheIndex

Then without the "?" the below:
using the index no you got in the line before and using the right sheet and pivottable name
ActiveSheet.PivotTables("PivotTable1").CacheIndex = 1

Additional resource:
 
Upvote 0
Welcome to the MrExcel Message Board! :)

Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!

Cross posted at:

There is no need to repeat the link(s) provided above but if you have posted the question at other places, please provide links to those as well.

If you do cross-post in the future and also provide links, then there shouldn’t be a problem.
 
Upvote 0
Welcome to the MrExcel Message Board! :)

Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!

Cross posted at:

There is no need to repeat the link(s) provided above but if you have posted the question at other places, please provide links to those as well.

If you do cross-post in the future and also provide links, then there shouldn’t be a problem.
Sorry for that, I´ll make sure to avoid this next time.
 
Upvote 0
Please read the rule. We have no problem with you doing it, you just need to provide the links. ;)
 
Upvote 0
You will need to have the right sheet active and put in your pivot table name
? ActiveSheet.PivotTables("PivotTable6").CacheIndex

Then without the "?" the below:
using the index no you got in the line before and using the right sheet and pivottable name
ActiveSheet.PivotTables("PivotTable1").CacheIndex = 1

Additional resource:

Thank you Alex for your reply.

I'm getting this error
1727366720969.png


I think I've found the one I used before:

?ActiveCell.PivotTable.cacheIndex
ActiveCell.PivotTable.cacheIndex = # (result from previous syntax)

For both cases I got the same error, I read about the error possible causes but I couldn´t get it fixed.

Any suggestion? Thanks in advance.
 

Attachments

  • 1727366150653.png
    1727366150653.png
    9 KB · Views: 1
Upvote 0
Please read the rule. We have no problem with you doing it, you just need to provide the links. ;)
I think that is the only other place where I posted the question, and I've read the rule # 13 and also the ExcelGuru article about cross posting. You mentioned there is no need to repeat the link, only to add if there is more than one. At this point nothing else to do right? I´m not used to post on forums but open to follow the rules..

I´ll make sure to post in the other site the solution once I found it.

Regards
 
Upvote 0
At this point nothing else to do right?
Correct. :) It was only because you said "I´ll make sure to avoid this next time" which gave me the impression you thought you weren't allowed to cross-post at all.
 
Upvote 0

Forum statistics

Threads
1,223,937
Messages
6,175,512
Members
452,650
Latest member
Tinfish

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