Hello,
I am currently trying to create filter that would update pivot table based on named range. So far I have following code:
Sub Pivot_Filter()
Dim myArray() As Variant
Dim myR As Range
Set myR = Application.InputBox(Prompt:="Please Select Range", Title:="Range Select", Type:=8)
ReDim myArray(0 To myR.Cells.Count - 1)
For i = 0 To myR.Cells.Count - 1
myArray(i) = "[Filter].[Filter 1].[Filter 2]".&[" & myR.Cells(i + 1).Value & "]"
Next i
ActiveSheet.PivotTables("Pivot Table 1").PivotFields("[Filter].[Filter 1].[Filter 2]").VisibleItemsList = myArray
End Sub
My problem is when I run the macro I get Error 1004 "Application-defined or Object-defined error"
If you know how to fix it your help would save me a lot of time when filtering manualy,
Thank you for your help
Bookmarks