I am working on recording the below macro to go from Sheet to Sheet to each Pivot and Add a new data field for the current month. I'd like to be able to add a prompt when I run the macro to allow me to input the month (format would be 008.2018 for example) and everywhere in the code below where the date/month is referenced would change with that single prompt input, can someone help with that??
Sub AddNewField()
'
' AddNewField Macro
'
'
Sheets("App Services").Select
ActiveSheet.PivotTables("AppServices_1").PivotSelect "'Resouce Hours'[All]", _
xlLabelOnly + xlFirstRow, True
ActiveSheet.PivotTables("AppServices_1").AddDataField ActiveSheet.PivotTables( _
"AppServices_1").PivotFields("008.2018"), "Count of 008.2018", xlCount
With ActiveSheet.PivotTables("AppServices_1").PivotFields("Count of 008.2018")
.Caption = "Sum of 008.2018"
.Function = xlSum
End With
Range("C218").Select
ActiveSheet.PivotTables("AppServices_2").AddDataField ActiveSheet.PivotTables( _
"AppServices_2").PivotFields("008.2018"), "Count of 008.2018", xlCount
With ActiveSheet.PivotTables("AppServices_2").PivotFields("Count of 008.2018")
.Caption = "Sum of 008.2018"
.Function = xlSum
End With
Sheets("EU_ASIA Apps").Select
Range("C159").Select
ActiveSheet.PivotTables("EUASIA_1").AddDataField ActiveSheet.PivotTables( _
"EUASIA_1").PivotFields("008.2018"), "Count of 008.2018", xlCount
With ActiveSheet.PivotTables("EUASIA_1").PivotFields("Count of 008.2018")
.Caption = "Sum of 008.2018"
.Function = xlSum
End With
Range("C181").Select
ActiveSheet.PivotTables("EUASIA_2").AddDataField ActiveSheet.PivotTables( _
"EUASIA_2").PivotFields("008.2018"), "Count of 008.2018", xlCount
With ActiveSheet.PivotTables("EUASIA_2").PivotFields("Count of 008.2018")
.Caption = "Sum of 008.2018"
.Function = xlSum
End With
Sheets("FORCE_GIC_IG_PCS").Select
Range("C207").Select
ActiveSheet.PivotTables("FORCEGIC_1").AddDataField ActiveSheet.PivotTables( _
"FORCEGIC_1").PivotFields("008.2018"), "Count of 008.2018", xlCount
With ActiveSheet.PivotTables("FORCEGIC_1").PivotFields("Count of 008.2018")
.Caption = "Sum of 008.2018"
.Function = xlSum
End With
Range("C235").Select
ActiveSheet.PivotTables("FORCEGIC_2").AddDataField ActiveSheet.PivotTables( _
"FORCEGIC_2").PivotFields("008.2018"), "Count of 008.2018", xlCount
With ActiveSheet.PivotTables("FORCEGIC_2").PivotFields("Count of 008.2018")
.Caption = "Sum of 008.2018"
.Function = xlSum
End With
Sheets("GBS").Select
Range("C171").Select
ActiveSheet.PivotTables("GBS_1").AddDataField ActiveSheet.PivotTables("GBS_1"). _
PivotFields("008.2018"), "Count of 008.2018", xlCount
With ActiveSheet.PivotTables("GBS_1").PivotFields("Count of 008.2018")
.Caption = "Sum of 008.2018"
.Function = xlSum
End With
Range("C199").Select
ActiveSheet.PivotTables("GBS_2").AddDataField ActiveSheet.PivotTables("GBS_2"). _
PivotFields("008.2018"), "Count of 008.2018", xlCount
With ActiveSheet.PivotTables("GBS_2").PivotFields("Count of 008.2018")
.Caption = "Sum of 008.2018"
.Function = xlSum
End With
Sheets("IIS").Select
Range("C169").Select
ActiveSheet.PivotTables("IIS_1").AddDataField ActiveSheet.PivotTables("IIS_1"). _
PivotFields("008.2018"), "Count of 008.2018", xlCount
With ActiveSheet.PivotTables("IIS_1").PivotFields("Count of 008.2018")
.Caption = "Sum of 008.2018"
.Function = xlSum
End With
ActiveSheet.PivotTables("IIS_2").PivotSelect "PPMC Name", xlButton, True
Range("C197").Select
ActiveSheet.PivotTables("IIS_2").AddDataField ActiveSheet.PivotTables("IIS_2"). _
PivotFields("008.2018"), "Count of 008.2018", xlCount
With ActiveSheet.PivotTables("IIS_2").PivotFields("Count of 008.2018")
.Caption = "Sum of 008.2018"
.Function = xlSum
End With
Sheets("IIS").Select
End Sub
Sub AddNewField()
'
' AddNewField Macro
'
'
Sheets("App Services").Select
ActiveSheet.PivotTables("AppServices_1").PivotSelect "'Resouce Hours'[All]", _
xlLabelOnly + xlFirstRow, True
ActiveSheet.PivotTables("AppServices_1").AddDataField ActiveSheet.PivotTables( _
"AppServices_1").PivotFields("008.2018"), "Count of 008.2018", xlCount
With ActiveSheet.PivotTables("AppServices_1").PivotFields("Count of 008.2018")
.Caption = "Sum of 008.2018"
.Function = xlSum
End With
Range("C218").Select
ActiveSheet.PivotTables("AppServices_2").AddDataField ActiveSheet.PivotTables( _
"AppServices_2").PivotFields("008.2018"), "Count of 008.2018", xlCount
With ActiveSheet.PivotTables("AppServices_2").PivotFields("Count of 008.2018")
.Caption = "Sum of 008.2018"
.Function = xlSum
End With
Sheets("EU_ASIA Apps").Select
Range("C159").Select
ActiveSheet.PivotTables("EUASIA_1").AddDataField ActiveSheet.PivotTables( _
"EUASIA_1").PivotFields("008.2018"), "Count of 008.2018", xlCount
With ActiveSheet.PivotTables("EUASIA_1").PivotFields("Count of 008.2018")
.Caption = "Sum of 008.2018"
.Function = xlSum
End With
Range("C181").Select
ActiveSheet.PivotTables("EUASIA_2").AddDataField ActiveSheet.PivotTables( _
"EUASIA_2").PivotFields("008.2018"), "Count of 008.2018", xlCount
With ActiveSheet.PivotTables("EUASIA_2").PivotFields("Count of 008.2018")
.Caption = "Sum of 008.2018"
.Function = xlSum
End With
Sheets("FORCE_GIC_IG_PCS").Select
Range("C207").Select
ActiveSheet.PivotTables("FORCEGIC_1").AddDataField ActiveSheet.PivotTables( _
"FORCEGIC_1").PivotFields("008.2018"), "Count of 008.2018", xlCount
With ActiveSheet.PivotTables("FORCEGIC_1").PivotFields("Count of 008.2018")
.Caption = "Sum of 008.2018"
.Function = xlSum
End With
Range("C235").Select
ActiveSheet.PivotTables("FORCEGIC_2").AddDataField ActiveSheet.PivotTables( _
"FORCEGIC_2").PivotFields("008.2018"), "Count of 008.2018", xlCount
With ActiveSheet.PivotTables("FORCEGIC_2").PivotFields("Count of 008.2018")
.Caption = "Sum of 008.2018"
.Function = xlSum
End With
Sheets("GBS").Select
Range("C171").Select
ActiveSheet.PivotTables("GBS_1").AddDataField ActiveSheet.PivotTables("GBS_1"). _
PivotFields("008.2018"), "Count of 008.2018", xlCount
With ActiveSheet.PivotTables("GBS_1").PivotFields("Count of 008.2018")
.Caption = "Sum of 008.2018"
.Function = xlSum
End With
Range("C199").Select
ActiveSheet.PivotTables("GBS_2").AddDataField ActiveSheet.PivotTables("GBS_2"). _
PivotFields("008.2018"), "Count of 008.2018", xlCount
With ActiveSheet.PivotTables("GBS_2").PivotFields("Count of 008.2018")
.Caption = "Sum of 008.2018"
.Function = xlSum
End With
Sheets("IIS").Select
Range("C169").Select
ActiveSheet.PivotTables("IIS_1").AddDataField ActiveSheet.PivotTables("IIS_1"). _
PivotFields("008.2018"), "Count of 008.2018", xlCount
With ActiveSheet.PivotTables("IIS_1").PivotFields("Count of 008.2018")
.Caption = "Sum of 008.2018"
.Function = xlSum
End With
ActiveSheet.PivotTables("IIS_2").PivotSelect "PPMC Name", xlButton, True
Range("C197").Select
ActiveSheet.PivotTables("IIS_2").AddDataField ActiveSheet.PivotTables("IIS_2"). _
PivotFields("008.2018"), "Count of 008.2018", xlCount
With ActiveSheet.PivotTables("IIS_2").PivotFields("Count of 008.2018")
.Caption = "Sum of 008.2018"
.Function = xlSum
End With
Sheets("IIS").Select
End Sub