PDA

View Full Version : Create Multiple Charts from a Pivot Table



kreepa
12-20-2007, 03:42 PM
Hey guys,

I'm trying to create a macro that will go through a pivot table and graph seperate charts for every unique pivot row. Is there anyway to do this?
Instead of cell references, I am sure I will have to use GetPivotData and different methods to reference the data. I'm stuck at this time. Any suggestions on how to accomplish something like this.

Sub CreateDemand_VS_SupplyAreaGraph()
'
' CreateDemand_VS_SupplyAreaGraph Macro
' Macro recorded 12/11/2007 by Keith V. McKnight
'
'
Charts.Add
ActiveChart.ChartType = xlAreaStacked
ActiveChart.SetSourceData Source:=Sheets("Test Page").Range("D18")
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(1).XValues = "=Supply!R56C7:R56C21"
ActiveChart.SeriesCollection(1).Values = "='Demand Pivot'!R5C3:R5C17"
ActiveChart.SeriesCollection(1).Name = "='Demand Pivot'!R5C2"
ActiveChart.SeriesCollection(2).Values = "='Demand Pivot'!R6C3:R6C17"
ActiveChart.SeriesCollection(2).Name = "='Demand Pivot'!R6C2"
ActiveChart.SeriesCollection(3).Values = "='Demand Pivot'!R7C3:R7C17"
ActiveChart.SeriesCollection(3).Name = "='Demand Pivot'!R7C2"
ActiveChart.Location Where:=xlLocationAsObject, Name:="TEST PAGE"

End Sub