I have a macro that calls a pivot table that populates a pivot chart. I set a filter in the pivot table to show me a list of data points. This updates my chart with the selected data points. I want to select each of those data points and change the fill color to blue.
I've set up the macro so that it effectively selects the first data point and changes it to blue fill color.
I'd like to know how to count the number of data points and then loop through the macro that number of times to set all of the data points to blue. In the example below there are 11 data points. The number of data points can change from day to day.
How do I count the number of data points, and then how do I loop through that number of data points to change the color?
Sub SetDemColor()
'
' SetDemColor Macro
'
'
Sheets("pivot").Select
ActiveSheet.PivotTables("PivotTable3").ClearAllFilters
ActiveSheet.PivotTables("PivotTable3").PivotFields("PARTY").ClearAllFilters
ActiveSheet.PivotTables("PivotTable3").PivotFields("PARTY").CurrentPage = _
"DEMOCRAT"
Sheets("chart").Select
ActiveSheet.ChartObjects("Chart 2").Activate
ActiveChart.PlotArea.Select
ActiveChart.SeriesCollection(1).Select
ActiveChart.SeriesCollection(1).Points(11).Select
With Selection.Format.Fill
.Visible = msoTrue
.ForeColor.RGB = RGB(0, 112, 192)
.Transparency = 0
.Solid
End With
End Sub
Bookmarks