mamafich

New Member
Joined
Sep 17, 2013
Messages
3
Hi everyone,

I've been searching to find a way of changing my pivot table data source from Access file to a local excel sheet (of same file). Is that anyhow possible?

When I select "Change Data Source" From PivotTable Tools / Options, it only allows me to select the second option, "Use an external data source".

I've tried to do it on VBA as well, but I guess I have some points missing therefore I got error. I've used below code and it gives the error - "Run-time error 5 - invalid procedure call or argument"

Code:
    ActiveSheet.PivotTables("PivotTable1").ChangePivotCache ActiveWorkbook. _
         PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
        "Sheet1!R89C64:R1265C120", Version:=xlPivotTableVersion14)

Could you please help me if it's possible? I've set all charts and calculations based on that pivot table, and I really don't want to start from the beginning.

Thanks a lot!
Cheers,

Selim
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
any suggestions?
It's been a while since you asked, but I had this same problem and just discovered a solution.

1. Create a new pivot table based on the new data source (it can just be empty).
2. Click in the new pivot.
3. In the immediate window type "? selection.pivottable.cacheindex" and press enter.
4. Note the index number of the pivot cache.
5. In Excel click in the old pivot which you want to change.
6. In the immediate window type "selection.pivottable.cacheindex = x" where x is the index number you noted in step 4.
7. Repeat step 6 for every pivot table which you want to use the new source.
8. Remove the table you created in step 1.

There may to change all tables from one cache to another in a single step, but it's probably not something you need to do often.
 
Upvote 0
It's been a while since you asked, but I had this same problem and just discovered a solution.

1. Create a new pivot table based on the new data source (it can just be empty).
2. Click in the new pivot.
3. In the immediate window type "? selection.pivottable.cacheindex" and press enter.
4. Note the index number of the pivot cache.
5. In Excel click in the old pivot which you want to change.
6. In the immediate window type "selection.pivottable.cacheindex = x" where x is the index number you noted in step 4.
7. Repeat step 6 for every pivot table which you want to use the new source.
8. Remove the table you created in step 1.

There may to change all tables from one cache to another in a single step, but it's probably not something you need to do often.


I know this thread's old but it was extremely helpful and I didn't know what immediate window meant, so I thought I'd elaborate as I was caught up on step 3 for a few minutes.

The immediate window is located within the Visual Basic Editor window, you can open it with Alt+F11
Once the Visual Basic window is open Ctrl+G will launch the Immediate window, now you can type steps 3 and 6 in here.
 
Upvote 0
Great thanks for the notes! It is indeed extremely helpful and save me a lot of time!

I know this thread's old but it was extremely helpful and I didn't know what immediate window meant, so I thought I'd elaborate as I was caught up on step 3 for a few minutes.

The immediate window is located within the Visual Basic Editor window, you can open it with Alt+F11
Once the Visual Basic window is open Ctrl+G will launch the Immediate window, now you can type steps 3 and 6 in here.
 
Upvote 0
Hi,

It worked perfectly to change the source, but it also deleted all the calculated items I had configured.... just fyi in case others find this thread later
 
Upvote 0

Forum statistics

Threads
1,214,515
Messages
6,119,974
Members
448,934
Latest member
audette89

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