I am looking to create a VBA macro that has the ability to update one pivot table filter based on multiple cell values. I have successfully been able to create VBA code to update the pivot table filter with ONE value but would like to modify this code to update the filter with MULTIPLE values.
Below is the code where I have successfully been able to update with ONE value:
Sub TEST()
'
' TEST Macro
'
Dim pt As PivotTable
Dim Field As PivotField
Dim NewCat As String
Set pt = Worksheets("CATALOG_DATABASE").PivotTables("PivotTable2")
Set Field = pt.PivotFields("Item #")
NewCat = Worksheets("INVOICE").Range("U18").Value
With pt
Field.ClearAllFilters
Field.CurrentPage = NewCat
pt.RefreshTable
End With
End Sub
My range of values that I would like to pull from is on Worksheet("INVOICE"), Range(S1:S15). Although this range goes down 15 rows, not all rows may have a value (case by case basis depending on invoice).
I am pretty new to writing VBA code but am looking for any help to achieve this goal.
Thank you,
Tyler
Below is the code where I have successfully been able to update with ONE value:
Sub TEST()
'
' TEST Macro
'
Dim pt As PivotTable
Dim Field As PivotField
Dim NewCat As String
Set pt = Worksheets("CATALOG_DATABASE").PivotTables("PivotTable2")
Set Field = pt.PivotFields("Item #")
NewCat = Worksheets("INVOICE").Range("U18").Value
With pt
Field.ClearAllFilters
Field.CurrentPage = NewCat
pt.RefreshTable
End With
End Sub
My range of values that I would like to pull from is on Worksheet("INVOICE"), Range(S1:S15). Although this range goes down 15 rows, not all rows may have a value (case by case basis depending on invoice).
I am pretty new to writing VBA code but am looking for any help to achieve this goal.
Thank you,
Tyler