ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   creating pivot charts from multiple pages (https://www.excelbanter.com/excel-programming/329909-creating-pivot-charts-multiple-pages.html)

lewscannon

creating pivot charts from multiple pages
 
I am trying to write a macro that creates seperate pivot charts for the
different pages of a pivot table. What I'm doing now returns the data of the
same page on 2 different charts.

' Loop through each client

For Each PivItem In PT.PivotFields("Client").PivotItems
Ctr = Ctr + 1
PT.PivotFields("Client").CurrentPage = PivItem.Name
PT.ManualUpdate = False
PT.ManualUpdate = True


' create the chart

Charts.Add
ActiveChart.SetSourceData Source:=Sheets("data").Range("Am4")
ActiveChart.Location Whe=xlLocationAsNewSheet
ActiveChart.ChartType = xlColumnClustered
ActiveChart.ApplyDataLabels Type:=xlDataLabelsShowValue,
LegendKey:=False, _
HasLeaderLines:=True

With Selection.Font
.Name = "Arial"
.FontStyle = "Bold"
.Size = 12
End With
ActiveChart.PlotArea.Select
With Selection.Border
.ColorIndex = 16
.Weight = xlThin
.LineStyle = xlContinuous
End With
Selection.Interior.ColorIndex = xlNone
ActiveChart.Axes(xlValue).MajorGridlines.Select
With Selection.Border
.ColorIndex = 15
.Weight = xlHairline
.LineStyle = xlContinuous
End With

ActiveSheet.Name = PivItem.Name & " Att Chart"

Next PivItem

Why am I not getting the different clients (pages) on different sheets?



All times are GMT +1. The time now is 03:16 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com