David_Excel
New Member
- Joined
- May 7, 2013
- Messages
- 10
Hi,
I 've been trying to change a pivot table filter depending on the value in cell a1, and whilst there are numerous examples on how to do this, I seem to keep getting errors where others do not. Here is the simple code that I'm using:
Sub PivotsUpdate()
Sheets("Herd_Structure").Select
Worksheets("Herd_Structure").PivotTables("PivotTable9").PivotFields("Location").ClearAllFilters
Worksheets("Herd_Structure").PivotTables("PivotTable9").PivotFields("Location").CurrentPage = Range("a1")
End Sub
Clearing all filters works fine (selects all options, but apparently this is normal), but it won't then select the item in cell a1 from the list of locations. Cell a1 is a text value if that makes any difference.
I get a runtime error 1004, application/object defined error on the penultimate line, where I try to select range a1 as my location.
Can anyone offer any assistance please?
Thanks, David
I 've been trying to change a pivot table filter depending on the value in cell a1, and whilst there are numerous examples on how to do this, I seem to keep getting errors where others do not. Here is the simple code that I'm using:
Sub PivotsUpdate()
Sheets("Herd_Structure").Select
Worksheets("Herd_Structure").PivotTables("PivotTable9").PivotFields("Location").ClearAllFilters
Worksheets("Herd_Structure").PivotTables("PivotTable9").PivotFields("Location").CurrentPage = Range("a1")
End Sub
Clearing all filters works fine (selects all options, but apparently this is normal), but it won't then select the item in cell a1 from the list of locations. Cell a1 is a text value if that makes any difference.
I get a runtime error 1004, application/object defined error on the penultimate line, where I try to select range a1 as my location.
Can anyone offer any assistance please?
Thanks, David