Control Pivot report filter with change of cell content?

Matrixx2525

New Member
Joined
Feb 4, 2017
Messages
8
Hello all,

I'm trying to control a reportfilter "KPI" in a pivottable, and the control should be with the content of a cell H6 on another sheet.
The sheetname of the pivottable is "Pivots", sheetname of controlling cell H6 is "Data".
Now, on dedicatedexcel.com I already found a VBA solution, which works with Worksheet_SelectionChange, and it works because it checks for a manual change in cell H6:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

'This line stops the worksheet updating on every change, it only updates when cell
'H6 is touched
If Intersect(Target, Range("H6")) Is Nothing Then Exit Sub

'Set the Variables to be used
Dim pt As PivotTable
Dim Field As PivotField
Dim NewCat As String

'Here you amend to suit your data
Set pt = Worksheets("Pivots").PivotTables("PivotTable1")
Set Field = pt.PivotFields("KPI")
NewCat = Worksheets("Data").Range("H6").Value

'This updates and refreshes the PIVOT table
With pt
Field.ClearAllFilters
Field.CurrentPage = NewCat
pt.RefreshTable
End With

End Sub

Now, the problem is that the contents of cell H6 is NOT a value entered manually, but a formula (="H20"). Also cell H20 is controlled not manually but with other formulas.
Because the content of cell H6 is a formula, above VBA does not work because that VBA waits for a cell to be touched physically by the user.

Does anybody know how I can change the report filter of the pivot, using the RESULT of the formula in cell H6, instead of waiting for somebody to click on the cell H6?

Thanks a million for your help guys and girls!

Best wishes,

Jeroen
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.

Forum statistics

Threads
1,216,098
Messages
6,128,812
Members
449,468
Latest member
AGreen17

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top