Basically, I have multiple tabs I am putting together, each with multiple pivots, where each pivot has multiple filters built in. These need to be visible to confirm the data you are seeing, since non-developers wouldn't know, how to access or understand VBA code.
What I want: Pivot table filters to be over each other in a list form:
What I currently get:
Here is a simplified version of the code...please let me know if there is a better way of doing this!
I tried using the Record Macro button in excel and format everything as I wanted to see, but once I actually run the macro, the filters are side by side rather than on top of each other.
Sub Macro5()
Columns("A:A").Select
Range(Selection, Selection.End(xlToRight)).Select
Application.CutCopyMode = False
Dim dataname As String
Dim datasheetname As String
Dim pivotsheetname As String
dataname = ActiveSheet.ListObjects(1).Name
datasheetname = ActiveSheet.Name
pivotsheetname = datasheetname & " Pivot"
Sheets.Add
ActiveSheet.Name = pivotsheetname
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
dataname, Version:=6).CreatePivotTable TableDestination:= _
"'" & pivotsheetname & "'!R3C1", TableName:="PivotTable15",
DefaultVersion:=6
Sheets(pivotsheetname).Select
Cells(3, 1).Select
With ActiveSheet.PivotTables("PivotTable15")
.ColumnGrand = False
.HasAutoFormat = True
.DisplayErrorString = False
.DisplayNullString = True
.EnableDrilldown = True
.ErrorString = ""
.MergeLabels = False
.NullString = ""
.PageFieldOrder = 2
.PageFieldWrapCount = 0
.PreserveFormatting = True
.RowGrand = False
.SaveData = True
.PrintTitles = False
.RepeatItemsOnEachPrintedPage = True
.TotalsAnnotation = False
.CompactRowIndent = 3
.InGridDropZones = False
.DisplayFieldCaptions = True
.DisplayMemberPropertyTooltips = False
.DisplayContextTooltips = True
.ShowDrillIndicators = True
.PrintDrillIndicators = False
.AllowMultipleFilters = False
.SortUsingCustomLists = True
.FieldListSortAscending = False
.ShowValuesRow = False
.CalculatedMembersInFilters = False
.RowAxisLayout xlTabularRow
End With
With ActiveSheet.PivotTables("PivotTable15").PivotCache
.RefreshOnFileOpen = False
.MissingItemsLimit = xlMissingItemsDefault
End With
ActiveSheet.PivotTables("PivotTable15").RepeatAllLabels xlRepeatLabels
With ActiveSheet.PivotTables("PivotTable15").PivotFields("Billable?")
.Orientation = xlPageField
.Position = 1
End With
With ActiveSheet.PivotTables("PivotTable15").PivotFields("Billed")
.Orientation = xlPageField
.Position = 1
End With
With ActiveSheet.PivotTables("PivotTable15").PivotFields("Amount")
enter code here .Orientation = xlPageField
.Position = 1
End With
ActiveSheet.PivotTables("PivotTable15").AddDataField
ActiveSheet.PivotTables( _
"PivotTable15").PivotFields("Qty"), "Sum of Qty", xlSum
End Sub