Need help changing Pivot Table source data

Bagharmin

Board Regular
Joined
Nov 22, 2010
Messages
168
I have a Pivot Table that is based on data contained on another worksheet in the same workbook. The number of rows in the source data changes from time to time. I want to refresh the Pivot Table in the macro that changes the number of rows in the source data, but I keep getting an "Object doesn't support this property or method" error. Here's the code in question:

Code:
    CurrAddress = "[" & ActiveWorkbook.Name & "]Data Restructure!R2C1:R" & LastRow & "C7"

    Worksheets("Pivot").PivotTable("MyPivot").ChangePivotCache ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:=CurrAddress)

Prior to the way it currently looks, I was getting an application/object defined error. I've changed it around several times, but can't seem to get it right. There is a PivotTable ("MyPivot") and a Pivot Chart on the "Pivot" worksheet that are linked together (changing the table changes the chart as well).

Thanks so much for the help. This is all I need to finish off the macro.
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Never mind. I changed

Code:
Worksheets("Pivot").PivotTable("MyPivot").ChangePivotCache ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:=CurrAddress)

to

Code:
Worksheets("Pivot").PivotTable[COLOR="#FF0000"][/COLOR][U][/U][I][/I][B]s[/B]("MyPivot").ChangePivotCache ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:=CurrAddress)

and it worked. One little letter ...
 
Upvote 0

Forum statistics

Threads
1,214,605
Messages
6,120,473
Members
448,967
Latest member
visheshkotha

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