Hi Experts,
I have many pivot tables on one sheet (Pivots) and a macro in that worksheet to change the filter based on cell value in A1. The macro runs if I manually input changes in cell A1 and hit enter in the sheet (Pivots), but the cell A1 is a value from a dropdown menu of a cell in another sheet (Master), the code I have thus far is
>>> use code - tags <<<
The above works fine when cell A1 is changed by typing the value and enter.
Is there any way the macro could run even though the cell 1 value changes based on the drop down menu in the Master sheet.
Tried the code but below and get run time error 1004, method 'Range' of object'_Worksheet failed.
Would much appreciate any help.
Even tried assigning a macro to a button to call the worksheet macro cannot seem to call the macro and get it to work
Thanks
Manu
I have many pivot tables on one sheet (Pivots) and a macro in that worksheet to change the filter based on cell value in A1. The macro runs if I manually input changes in cell A1 and hit enter in the sheet (Pivots), but the cell A1 is a value from a dropdown menu of a cell in another sheet (Master), the code I have thus far is
>>> use code - tags <<<
Code:
Sub Change_Filter1()
Dim ws As Worksheet
Dim pt As PivotTable
Dim pf As PivotField
Set ws = Sheets("Pivots")
For Each pt In ws.PivotTables
Set pf = Nothing
On Error Resume Next
Set pf = pt.PivotFields("Region")
pf.ClearAllFilters
pf.CurrentPage = Cells(1, 1).Value
Next pt
End Sub
The above works fine when cell A1 is changed by typing the value and enter.
Is there any way the macro could run even though the cell 1 value changes based on the drop down menu in the Master sheet.
Tried the code but below and get run time error 1004, method 'Range' of object'_Worksheet failed.
Code:
Sub Worksheet_Calculate()
Dim Rg As Range
Set Rg = Range("A1")
If Not Intersect(Rg, Range("A1")) Is Nothing Then
Dim ws As Worksheet
Dim pt As PivotTable
Dim pf As PivotField
Set ws = Sheets("Pivots")
For Each pt In ws.PivotTables
Set pf = Nothing
On Error Resume Next
Set pf = pt.PivotFields("Region")
pf.ClearAllFilters
pf.CurrentPage = Cells(1, 1).Value
Next pt
End If
End Sub
Even tried assigning a macro to a button to call the worksheet macro cannot seem to call the macro and get it to work
Thanks
Manu
Last edited by a moderator: