Hi
I've read a number of posts and I've got part way through on this problem but not all the way.
I have a spreadsheet which has a menu page where the user selects a business unit by inputting a value into a cell (using validation dropdown so spelling is correct)
I want this cell selection to drive a number of pivot page filters that sit on several other sheets.
I think my issue is that the pivots all come out of out Data warehouse so they have an olap format.
When I do a macro record I get this format for the field filter I want to change:
Here's what I have so far as sheet code on the sheet with the cell selection.
It's clears all the filters but it won't set them to the cell value. (the cell is called rBusiness_Unit_Change)
No error, it just doesn't do it.
Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
Application.EnableEvents = False
Application.ScreenUpdating = False
If Target.Address = Range("rBusiness_Unit_Change").Address Then
Assistance appreciated.
FYI: Using Excel 2010.
I've read a number of posts and I've got part way through on this problem but not all the way.
I have a spreadsheet which has a menu page where the user selects a business unit by inputting a value into a cell (using validation dropdown so spelling is correct)
I want this cell selection to drive a number of pivot page filters that sit on several other sheets.
I think my issue is that the pivots all come out of out Data warehouse so they have an olap format.
When I do a macro record I get this format for the field filter I want to change:
ActiveSheet.PivotTables("PivotTable8").PivotFields("[Cost Centre].[Business Unit].[Business Unit]").ClearAllFilters
Here's what I have so far as sheet code on the sheet with the cell selection.
It's clears all the filters but it won't set them to the cell value. (the cell is called rBusiness_Unit_Change)
No error, it just doesn't do it.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim ws As Worksheet
Dim pt As PivotTable
Const BUField As String = "[Cost Centre].[Business Unit].[Business Unit]"
Dim NewBusinessUnit As String
NewBusinessUnit = Range("rBusiness_Unit_Change").Value
Dim pt As PivotTable
Const BUField As String = "[Cost Centre].[Business Unit].[Business Unit]"
Dim NewBusinessUnit As String
NewBusinessUnit = Range("rBusiness_Unit_Change").Value
On Error Resume Next
Application.EnableEvents = False
Application.ScreenUpdating = False
If Target.Address = Range("rBusiness_Unit_Change").Address Then
For Each ws In ThisWorkbook.Worksheets
For Each pt In ws.PivotTables
With pt.PageFields(BUField)
For Each pt In ws.PivotTables
With pt.PageFields(BUField)
.ClearAllFilters
.CurrentPage = Array("[Cost Centre].[Business Unit].&[NewBusinessUnit]")
.CurrentPage = Array("[Cost Centre].[Business Unit].&[NewBusinessUnit]")
End With
Next pt
Next ws
End If
Application.EnableEvents = True
Application.ScreenUpdating = True
End SubNext ws
End If
Application.EnableEvents = True
Application.ScreenUpdating = True
Assistance appreciated.
FYI: Using Excel 2010.