My workbook consists of 2 sheets: Sheet1 is the primary dashboard that the user sees, while Sheet2 consists of a pivot table and regular table.
I'd like to implement some VBA code so that the user can click on some text in Sheet1 and the pivot table on Sheet2 will filter according to what text the user clicked on.
So for instance, Column A on Sheet1 is a list of US Cities. I'd like the user to be able to double click on a city name in Sheet1 and have the pivot table on Sheet2 filter to whatever the city name was clicked on.
I don't need the macro to actually bring the user to Sheet2. All I'm planning on doing is just referencing the pivot table on Sheet1.
I designed something similar using a standard table, but I really need this to work on the Pivot Table and I'm not sure how to go about it.
UPDATE
Ok so here is my code now:
Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Not Intersect(Target, Range("E:P")) Is Nothing Then
Application.ScreenUpdating = False
Worksheets("Dillon Pivot").PivotTables("PivotTable2").ManualUpdate = True
Worksheets("Dillon Pivot").PivotTables("PivotTable2").PivotFields("Match").ClearAllFilters
Worksheets("Dillon Pivot").PivotTables("PivotTable2").PivotFields("Match").CurrentPage = ActiveCell.Value
Worksheets("Dillon Pivot").PivotTables("PivotTable2").ManualUpdate = False
Application.ScreenUpdating = True
End If
End Sub
I want the user to be able to click a cell on the main dashboard and have the pivot table on "Dillon Pivot" be filtered.
However, when I double click a cell I get the following error: "Application-defined or object defined error"
Can anyone assist?