New with excel vba. I need to change the filter of the pivot table by letting the user type the filter that he wants. The cell range name is "region" and i have a button. Whenever the button is clicked, the pivot table filter should change depending on what was typed by the user. I tried the code below but i had a vba error: argument not optional.
Am i missing something here?
Sub changeFilter(Range As String)
Dim rng As Range
rng = Range(region)
ActiveSheet.PivotTables("PivotTable2").PivotFields("region").CurrentPage = rng