Create PivotChart from PivotTable

mattty

New Member
Joined
Nov 22, 2007
Messages
14
How can I create a PivotChart using VBA? I ran the macro recorder, and it referred to the source data in the standard way:
ActiveChart.SetSourceData Source:=Range("'sheet1'!$A$3:$C$25")

How do I create a chart that is specifically a PivotChart, referring to a PivotTable as a source, so that when the PT updates, so does the PC?

Seems like it should be a simple solution, but I have had no luck with this.
Thanks in advance!

PS I am using Excel 2007, but I don't think that should matter
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
bump.

sorry, can anyone help with this? I can think of a bunch of workarounds, but I'm sure that there must be some simple, more elegant, solution.

thanks.
 
Upvote 0
When you created the PT you could have created as PT Chart -- doing so would generate both PT & PT Chart simultaneously (I think) -- untested... try recreating.

I'll test myself in a bit...

EDIT: yes, creating as Pivot Chart in first instance will generate the PT -- thus the two are tied... altering one alters the other... so you should find your problem disappears.
 
Last edited:
Upvote 0
Yes, this method works, but it still refers to a PivotTable by its range, rather than by its name. Also, you need to be inserting PTs to begin with (mine already exist).

The solution I used - for the benefit of anyone reading this later on - was to create blank charts, then use code to fill them from the PTs.
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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