Hello,
the topic was already discussed in a different thread, however it rather seems dead and I did not receive any further feedback.
In the thread it was discussed to connect a cell within separate worksheet to a pivot table. The formula from the thread (below) works very well, however I want to include more than on filter that connect to different cells, for example I have a filter value in B2 and B3 and responds to MyReportField1 and the other one to ReportField2. I'm not really sure, where I can include that in the code below.
I would be very happy if someone could help out with that.
Thanks and best regards,
S.
the topic was already discussed in a different thread, however it rather seems dead and I did not receive any further feedback.
In the thread it was discussed to connect a cell within separate worksheet to a pivot table. The formula from the thread (below) works very well, however I want to include more than on filter that connect to different cells, for example I have a filter value in B2 and B3 and responds to MyReportField1 and the other one to ReportField2. I'm not really sure, where I can include that in the code below.
I would be very happy if someone could help out with that.
Thanks and best regards,
S.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Target.Address = Range("B2").Address Then Exit Sub
Dim PT As PivotTable
Dim ptItem As PivotItem
On Error Resume Next
For Each PT In Worksheets("Sheet1").PivotTables
With PT.PivotFields("MyReportField")
If .EnableMultiplePageItems = True Then
.ClearAllFilters
End If
Set ptItem = .PivotItems(Target.Value)
If Not ptItem Is Nothing Then
.CurrentPage = Target.Value
End If
End With
Next
End Sub