I have a pivot chart that I would like to make more interactive and allow the user to select which data they would like to see. I didn't know the code to do this so I recorded a macro of when I changed what was seen. I took one off, then brought it back and changed it so it would average the data. I then tried to run through the macro and it kept giving me an error. I have posted my code below. Once I can get the basics done on this I will go ahead and use if formulas with my checkboxes to make it work how I would like. Any help would be great.
Sub Macro15()
'
' Macro15 Macro
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveWorkbook.ShowPivotTableFieldList = True
ActiveChart.PivotLayout.PivotTable.PivotFields("Documented in Excel"). _
Orientation = xlHidden
ActiveWorkbook.ShowPivotTableFieldList = False
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveWorkbook.ShowPivotTableFieldList = True
ActiveChart.PivotLayout.PivotTable.AddDataField ActiveChart.PivotLayout. _
PivotTable.PivotFields("Documented in Excel"), "Sum of Documented in Excel", _
xlSum
With ActiveChart.PivotLayout.PivotTable.PivotFields( _
"Sum of Documented in Excel")
.Caption = "Average of Documented in Excel"
.Function = xlAverage
End With
ActiveWorkbook.ShowPivotTableFieldList = False
End Sub
Bookmarks