Hi All,
I'm trying to make the array below perform the subsequent actions. I apologize for the size of the macro; any help would be greatly appreciated. Thank you.
Sub FixPivots()
Application.ScreenUpdating = False
'I need this array:
Sheets(Array("AnalysisMeeker", "AnalysisWolk", "AnalysisHealy", "AnalysisJones", _
"AnalysisHarris", "AnalysisMunley", "AnalysisDouglas", "AnalysisRose", _
"AnalysisGiordano", "AnalysisBugg", "AnalysisClifford", "AnalysisSullivan", _
"AnalysisCalbreath", "AnalysisMeyers")).Select
'..to perform this (the rest of the code):
ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables( _
"PivotTable1").PivotFields("4/30/2015"), "Count of 4/30/2015", xlCount
ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables( _
"PivotTable1").PivotFields("3/31/2015"), "Count of 3/31/2015", xlCount
ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables( _
"PivotTable1").PivotFields("2/28/2015"), "Count of 2/28/2015", xlCount
ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables( _
"PivotTable1").PivotFields("1/31/2015"), "Count of 1/31/2015", xlCount
ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables( _
"PivotTable1").PivotFields("12/31/2014"), "Count of 12/31/2014", xlCount
ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables( _
"PivotTable1").PivotFields("11/30/2014"), "Count of 11/30/2014", xlCount
ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables( _
"PivotTable1").PivotFields("10/31/2014"), "Count of 10/31/2014", xlCount
ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables( _
"PivotTable1").PivotFields("9/30/2014"), "Count of 9/30/2014", xlCount
ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables( _
"PivotTable1").PivotFields("8/31/2014"), "Count of 8/31/2014", xlCount
ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables( _
"PivotTable1").PivotFields("7/31/2014"), "Count of 7/31/2014", xlCount
ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables( _
"PivotTable1").PivotFields("6/30/2014"), "Count of 6/30/2014", xlCount
ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables( _
"PivotTable1").PivotFields("5/31/2014"), "Count of 5/31/2014", xlCount
ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables( _
"PivotTable1").PivotFields("4/30/2014"), "Count of 4/30/2014", xlCount
ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables( _
"PivotTable1").PivotFields("3/31/2014"), "Count of 3/31/2014", xlCount
ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables( _
"PivotTable1").PivotFields("2/28/2014"), "Count of 2/28/2014", xlCount
ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables( _
"PivotTable1").PivotFields("1/31/2014"), "Count of 1/31/2014", xlCount
ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables( _
"PivotTable1").PivotFields("12/31/2013"), "Count of 12/31/2013", xlCount
ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables( _
"PivotTable1").PivotFields("11/30/2013"), "Count of 11/30/2013", xlCount
ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables( _
"PivotTable1").PivotFields("10/31/2013"), "Count of 10/31/2013", xlCount
ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables( _
"PivotTable1").PivotFields("9/30/2013"), "Count of 9/30/2013", xlCount
ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables( _
"PivotTable1").PivotFields("8/31/2013"), "Count of 8/31/2013", xlCount
ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables( _
"PivotTable1").PivotFields("7/31/2013"), "Count of 7/31/2013", xlCount
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Count of 7/31/2013")
.Caption = "Sum of 7/31/2013"
.Function = xlSum
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Count of 8/31/2013")
.Caption = "Sum of 8/31/2013"
.Function = xlSum
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Count of 9/30/2013")
.Caption = "Sum of 9/30/2013"
.Function = xlSum
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Count of 10/31/2013")
.Caption = "Sum of 10/31/2013"
.Function = xlSum
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Count of 11/30/2013")
.Caption = "Sum of 11/30/2013"
.Function = xlSum
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Count of 12/31/2013")
.Caption = "Sum of 12/31/2013"
.Function = xlSum
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Count of 1/31/2014")
.Caption = "Sum of 1/31/2014"
.Function = xlSum
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Count of 2/28/2014")
.Caption = "Sum of 2/28/2014"
.Function = xlSum
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Count of 3/31/2014")
.Caption = "Sum of 3/31/2014"
.Function = xlSum
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Count of 4/30/2014")
.Caption = "Sum of 4/30/2014"
.Function = xlSum
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Count of 5/31/2014")
.Caption = "Sum of 5/31/2014"
.Function = xlSum
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Count of 6/30/2014")
.Caption = "Sum of 6/30/2014"
.Function = xlSum
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Count of 7/31/2014")
.Caption = "Sum of 7/31/2014"
.Function = xlSum
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Count of 8/31/2014")
.Caption = "Sum of 8/31/2014"
.Function = xlSum
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Count of 9/30/2014")
.Caption = "Sum of 9/30/2014"
.Function = xlSum
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Count of 10/31/2014")
.Caption = "Sum of 10/31/2014"
.Function = xlSum
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Count of 11/30/2014")
.Caption = "Sum of 11/30/2014"
.Function = xlSum
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Count of 12/31/2014")
.Caption = "Sum of 12/31/2014"
.Function = xlSum
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Count of 1/31/2015")
.Caption = "Sum of 1/31/2015"
.Function = xlSum
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Count of 2/28/2015")
.Caption = "Sum of 2/28/2015"
.Function = xlSum
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Count of 3/31/2015")
.Caption = "Sum of 3/31/2015"
.Function = xlSum
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Count of 4/30/2015")
.Caption = "Sum of 4/30/2015"
.Function = xlSum
End With
Application.ScreenUpdating = True
End Sub
I'm trying to make the array below perform the subsequent actions. I apologize for the size of the macro; any help would be greatly appreciated. Thank you.
Sub FixPivots()
Application.ScreenUpdating = False
'I need this array:
Sheets(Array("AnalysisMeeker", "AnalysisWolk", "AnalysisHealy", "AnalysisJones", _
"AnalysisHarris", "AnalysisMunley", "AnalysisDouglas", "AnalysisRose", _
"AnalysisGiordano", "AnalysisBugg", "AnalysisClifford", "AnalysisSullivan", _
"AnalysisCalbreath", "AnalysisMeyers")).Select
'..to perform this (the rest of the code):
ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables( _
"PivotTable1").PivotFields("4/30/2015"), "Count of 4/30/2015", xlCount
ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables( _
"PivotTable1").PivotFields("3/31/2015"), "Count of 3/31/2015", xlCount
ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables( _
"PivotTable1").PivotFields("2/28/2015"), "Count of 2/28/2015", xlCount
ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables( _
"PivotTable1").PivotFields("1/31/2015"), "Count of 1/31/2015", xlCount
ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables( _
"PivotTable1").PivotFields("12/31/2014"), "Count of 12/31/2014", xlCount
ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables( _
"PivotTable1").PivotFields("11/30/2014"), "Count of 11/30/2014", xlCount
ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables( _
"PivotTable1").PivotFields("10/31/2014"), "Count of 10/31/2014", xlCount
ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables( _
"PivotTable1").PivotFields("9/30/2014"), "Count of 9/30/2014", xlCount
ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables( _
"PivotTable1").PivotFields("8/31/2014"), "Count of 8/31/2014", xlCount
ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables( _
"PivotTable1").PivotFields("7/31/2014"), "Count of 7/31/2014", xlCount
ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables( _
"PivotTable1").PivotFields("6/30/2014"), "Count of 6/30/2014", xlCount
ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables( _
"PivotTable1").PivotFields("5/31/2014"), "Count of 5/31/2014", xlCount
ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables( _
"PivotTable1").PivotFields("4/30/2014"), "Count of 4/30/2014", xlCount
ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables( _
"PivotTable1").PivotFields("3/31/2014"), "Count of 3/31/2014", xlCount
ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables( _
"PivotTable1").PivotFields("2/28/2014"), "Count of 2/28/2014", xlCount
ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables( _
"PivotTable1").PivotFields("1/31/2014"), "Count of 1/31/2014", xlCount
ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables( _
"PivotTable1").PivotFields("12/31/2013"), "Count of 12/31/2013", xlCount
ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables( _
"PivotTable1").PivotFields("11/30/2013"), "Count of 11/30/2013", xlCount
ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables( _
"PivotTable1").PivotFields("10/31/2013"), "Count of 10/31/2013", xlCount
ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables( _
"PivotTable1").PivotFields("9/30/2013"), "Count of 9/30/2013", xlCount
ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables( _
"PivotTable1").PivotFields("8/31/2013"), "Count of 8/31/2013", xlCount
ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables( _
"PivotTable1").PivotFields("7/31/2013"), "Count of 7/31/2013", xlCount
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Count of 7/31/2013")
.Caption = "Sum of 7/31/2013"
.Function = xlSum
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Count of 8/31/2013")
.Caption = "Sum of 8/31/2013"
.Function = xlSum
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Count of 9/30/2013")
.Caption = "Sum of 9/30/2013"
.Function = xlSum
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Count of 10/31/2013")
.Caption = "Sum of 10/31/2013"
.Function = xlSum
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Count of 11/30/2013")
.Caption = "Sum of 11/30/2013"
.Function = xlSum
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Count of 12/31/2013")
.Caption = "Sum of 12/31/2013"
.Function = xlSum
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Count of 1/31/2014")
.Caption = "Sum of 1/31/2014"
.Function = xlSum
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Count of 2/28/2014")
.Caption = "Sum of 2/28/2014"
.Function = xlSum
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Count of 3/31/2014")
.Caption = "Sum of 3/31/2014"
.Function = xlSum
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Count of 4/30/2014")
.Caption = "Sum of 4/30/2014"
.Function = xlSum
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Count of 5/31/2014")
.Caption = "Sum of 5/31/2014"
.Function = xlSum
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Count of 6/30/2014")
.Caption = "Sum of 6/30/2014"
.Function = xlSum
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Count of 7/31/2014")
.Caption = "Sum of 7/31/2014"
.Function = xlSum
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Count of 8/31/2014")
.Caption = "Sum of 8/31/2014"
.Function = xlSum
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Count of 9/30/2014")
.Caption = "Sum of 9/30/2014"
.Function = xlSum
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Count of 10/31/2014")
.Caption = "Sum of 10/31/2014"
.Function = xlSum
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Count of 11/30/2014")
.Caption = "Sum of 11/30/2014"
.Function = xlSum
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Count of 12/31/2014")
.Caption = "Sum of 12/31/2014"
.Function = xlSum
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Count of 1/31/2015")
.Caption = "Sum of 1/31/2015"
.Function = xlSum
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Count of 2/28/2015")
.Caption = "Sum of 2/28/2015"
.Function = xlSum
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Count of 3/31/2015")
.Caption = "Sum of 3/31/2015"
.Function = xlSum
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Count of 4/30/2015")
.Caption = "Sum of 4/30/2015"
.Function = xlSum
End With
Application.ScreenUpdating = True
End Sub