AboveBeyond
Board Regular
- Joined
- Aug 14, 2007
- Messages
- 114
Hi, I have a VBA code that filters PT based on a the values of a specific cell. However, this only seems to work on non-SSAS connected data source. I believe the reason why this code doesn't work is because my data source is a SSAS PT, the field "Code" doesn't actually list the values until the expand "+" sign is clicked.
Is there a way to make the code work with a SSAS PT?
Is there a way to make the code work with a SSAS PT?
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 GoTo CleanUp
Application.EnableEvents = False
For Each pt In Worksheets("Sheet1").PivotTables
With pt.PivotFields("Code")
If .EnableMultiplePageItems = True Then
.ClearAllFilters
End If
If LCase$(Target.Value) = "all" Then
.ClearAllFilters
Else
Set ptItem = .PivotItems(Target.Value)
If Not ptItem Is Nothing Then
.CurrentPage = Target.Value
End If
End If
End With
Next
CleanUp:
Application.EnableEvents = True
End Sub
Last edited: