Sub Pivot()
Application.ScreenUpdating = False
Dim shtSrc As Worksheet, shtDest As Worksheet
Dim pc As PivotCache
Set shtSrc = ActiveSheet
Set shtDest = shtSrc.Parent.Sheets.Add()
Set pc = ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, _
SourceData:=shtSrc.Cells(1).CurrentRegion.Address)
pc.CreatePivotTable TableDestination:=shtDest.Range("A3"), _
TableName:="PivotTable1"
With shtDest.PivotTables("PivotTable1")
.InGridDropZones = True
.RowAxisLayout xlTabularRow
End With
''''''''''''''''''''''''''''''''''''''''''''''''''''
With ActiveSheet.PivotTables("PivotTable1").PivotFields("BUILDING_LOCID")
.Orientation = xlPageField
.Position = 1
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("OPTION_CODE")
.Orientation = xlPageField
.Position = 1
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("OPTION_STATUS_NAME")
.Orientation = xlPageField
.Position = 1
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("LINE_ITEM_TYPE")
.Orientation = xlPageField
.Position = 1
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("LINEITEM")
.Orientation = xlRowField
.Position = 1
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("C_YEAR")
.Orientation = xlColumnField
.Position = 1
End With
ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables( _
"PivotTable1").PivotFields("ACTUALS_RO"), "Sum of ACTUALS_RO", xlSum
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Sum of ACTUALS_RO")
.NumberFormat = "$#,##0.00"
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("LINEITEM")
.PivotItems("CS Total - P&L").Visible = False
End With
ActiveSheet.PivotTables("PivotTable1").PivotFields("OPTION_STATUS_NAME"). _
ClearAllFilters
ActiveSheet.PivotTables("PivotTable1").PivotFields("OPTION_STATUS_NAME"). _
CurrentPage = "Forecast"
ActiveSheet.PivotTables("PivotTable1").PivotFields("LINE_ITEM_TYPE"). _
ClearAllFilters
ActiveSheet.PivotTables("PivotTable1").PivotFields("LINE_ITEM_TYPE"). _
CurrentPage = "P&L"
Range("A1:H15").Select
Selection.Copy
Range("A18").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Selection.Copy
Range("A35").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWindow.SmallScroll Down:=24
Selection.Copy
Range("A52").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWindow.SmallScroll Down:=9
Selection.Copy
Range("A69").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWindow.SmallScroll Down:=-51
ActiveSheet.PivotTables("PivotTable2").PivotFields("OPTION_CODE"). _
ClearAllFilters
ActiveSheet.PivotTables("PivotTable2").PivotFields("OPTION_CODE").CurrentPage _
= "ACT"
Range("A18").Select
ActiveSheet.PivotTables("PivotTable2").TableStyle2 = "PivotStyleLight17"
ActiveWindow.SmallScroll Down:=9
ActiveSheet.PivotTables("PivotTable3").PivotFields("OPTION_CODE"). _
ClearAllFilters
ActiveSheet.PivotTables("PivotTable3").PivotFields("OPTION_CODE").CurrentPage _
= "AUTO RENEWAL"
Range("A35").Select
ActiveSheet.PivotTables("PivotTable3").TableStyle2 = "PivotStyleLight18"
ActiveWindow.SmallScroll Down:=21
ActiveSheet.PivotTables("PivotTable4").PivotFields("OPTION_CODE"). _
ClearAllFilters
ActiveSheet.PivotTables("PivotTable4").PivotFields("OPTION_CODE").CurrentPage _
= "RO"
Range("B53").Select
ActiveSheet.PivotTables("PivotTable4").TableStyle2 = "PivotStyleLight19"
ActiveWindow.SmallScroll Down:=15
Range("B70").Select
ActiveSheet.PivotTables("PivotTable5").TableStyle2 = "PivotStyleLight15"
ActiveSheet.PivotTables("PivotTable5").PivotFields("Sum of ACTUALS_RO"). _
Orientation = xlHidden
ActiveSheet.PivotTables("PivotTable5").AddDataField ActiveSheet.PivotTables( _
"PivotTable5").PivotFields("FORECAST"), "Count of FORECAST", xlCount
With ActiveSheet.PivotTables("PivotTable5").PivotFields("Count of FORECAST")
.Caption = "Sum of FORECAST"
.Function = xlSum
.NumberFormat = "$#,##0.00"
End With
ActiveWindow.SmallScroll Down:=-72
Cells.Select
Selection.Columns.AutoFit
Range("A1").Select
End Sub