

- #HOW TO USE FILTERS IN PIVOT TABLES IN EXCEL 2013 HOW TO#
- #HOW TO USE FILTERS IN PIVOT TABLES IN EXCEL 2013 CODE#
Sub MakeTable() Dim ws As Worksheet Dim PTCache As PivotCache Dim pt As PivotTable Dim PivotDataRange As Range Set ws = Worksheets.Add Set PivotDataRange = Sheets("CleanData").Range("DataRange") Set PTCache = _ (SourceType:=xlDatabase, _ SourceData:=PivotDataRange, _ Version:=xlPivotTableVersion14) Set pt = PTCache.CreatePivotTable _ (TableDestination:=ws.Cells(10, 2), _ TableName:="allData2", _ DefaultVersion:=xlPivotTableVersion14)End Sub
#HOW TO USE FILTERS IN PIVOT TABLES IN EXCEL 2013 HOW TO#
If you want to know how to programmatically create a pivot table with a compatible pivot table version, here is the code: My troubleshooting advice for issues related to getting selected values would be to check the pivot table version for xlPivotTableVersion12 or greater. I recreated the pivot table in 2007 so that it was xlPivotTableVersion12.

At the end of the procedure, a pivot table name PivotTable1 will be created from this cache. Next, we are going to create myPivotCache to hold the replica of the data source. This pivot table version is not compatible with the functionality specified above. The myPivotTableStart variable determines where the Pivot Table starts. Even though I converted the workbook to 2007, the pivot table I was using was originally created in 2003 and as such, was xlPivotTableVersion10. Let me know if you need more info.ĭim pvtItem As PivotItemDim nwsheet As WorksheetDim rw As IntegerSet nwsheet = 0For Each pvtItem In Worksheets("qry ACT HoursParts").PivotTables("PivotTable1").PivotFields("Product Date").VisibleItems rw = rw + 1 nwsheet.Cells(rw, 1).Value = pvtItem.NameNextĪlthough I was using Excel 2007, the workbook was originally created in Excel 2003. So, in this simplified sample data set I have some employee records for allocations of charging stations. They wanted to use their Pivot Table to filter out duplicates in their data. This blog post is in response to a question by a subscriber. When I executed the procedure it only looped through once and the only output was the value "(All)". Hello and welcome to another blog post in my 2021 Excel tips series. I only selected two selections and the Multiple Selections Property is turned on (obviously).
#HOW TO USE FILTERS IN PIVOT TABLES IN EXCEL 2013 CODE#
I adapted the following code from the MSDN library.

I am filtering on a field called "Product Date", which has up to 8 date filters. I have a pivot table who's data source is from an odbc connection to a query in Access. I have the same exact question as this previously answered thread, except for Excel not Access
