I have created a macro to create a pivot table. I have recorded the macro and when I recorded it, all the filters on pivot macro stacked (image 1). However when I run the macro it is putting all the filters horizontally instead of stacking them on top of each other (image2). I would like my macro to run and show like the image 2 (stacked vertically).
'
' oepivot Macro
'
'
Application.CutCopyMode = False
Application.CutCopyMode = False
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"Sheet1!R1C1:R218205C31", Version:=8).CreatePivotTable TableDestination:= _
"CrossCheck!R1C1", TableName:="PivotTable9", DefaultVersion:=8
Sheets("CrossCheck").Select
Cells(1, 1).Select
With ActiveSheet.PivotTables("PivotTable9")
.ColumnGrand = True
.HasAutoFormat = True
.DisplayErrorString = False
.DisplayNullString = True
.EnableDrilldown = True
.ErrorString = ""
.MergeLabels = False
.NullString = ""
.PageFieldOrder = 2
.PageFieldWrapCount = 0
.PreserveFormatting = True
.RowGrand = True
.SaveData = True
.PrintTitles = False
.RepeatItemsOnEachPrintedPage = True
.TotalsAnnotation = False
.CompactRowIndent = 1
.InGridDropZones = False
.DisplayFieldCaptions = True
.DisplayMemberPropertyTooltips = False
.DisplayContextTooltips = True
.ShowDrillIndicators = True
.PrintDrillIndicators = False
.AllowMultipleFilters = False
.SortUsingCustomLists = True
.FieldListSortAscending = False
.ShowValuesRow = False
.CalculatedMembersInFilters = False
.RowAxisLayout xlCompactRow
End With
With ActiveSheet.PivotTables("PivotTable9").PivotCache
.RefreshOnFileOpen = False
.MissingItemsLimit = xlMissingItemsDefault
End With
ActiveSheet.PivotTables("PivotTable9").RepeatAllLabels xlRepeatLabels
With ActiveSheet.PivotTables("PivotTable9").PivotFields("Accounting Period")
.Orientation = xlPageField
.Position = 1
End With
With ActiveSheet.PivotTables("PivotTable9").PivotFields("Object")
.Orientation = xlPageField
.Position = 1
End With
With ActiveSheet.PivotTables("PivotTable9").PivotFields("Object Class")
.Orientation = xlPageField
.Position = 2
End With
Application.Width = 886.5
Application.Height = 661.5
With ActiveSheet.PivotTables("PivotTable9").PivotFields("Fiscal Year")
.Orientation = xlPageField
.Position = 1
End With
With ActiveSheet.PivotTables("PivotTable9").PivotFields("PE FILTER")
.Orientation = xlRowField
.Position = 1
End With
ActiveSheet.PivotTables("PivotTable9").AddDataField ActiveSheet.PivotTables( _
"PivotTable9").PivotFields("Jrnl Posting Code"), "Count of Jrnl Posting Code", _
xlCount
End Sub