Hi,
I have been trying to come up with a code that would help me filter the pivot table but with a variable different from the row/column/data fields. I tried page fields but looping .visible doesn't work and ends up with errors , especially those with continuous variable, the variable I'm looking at has decimal values.I want the same function as slicer but with a larger range of data. I tried this code,
Sub macro4()
Dim slicer As SlicerItem, i As Long
Dim pt1 As PivotTable
Set pt1 = ActiveSheet.PivotTables("PivotTable1")
pt1.ManualUpdate = True
Application.ScreenUpdating = False
Application.EnableEvents = False
With ActiveWorkbook.SlicerCaches("Slicer_ADD")
For i = 1 To .SlicerItems.Count
.SlicerItems(i).Selected = (Val(.SlicerItems(i).Value) > 100)
Next i
End With
pt1.ManualUpdate = False
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub
but it's too slow (haven't finished any run for the variable I want but it seems to be working for those with fewer values) and I still need to be able to interchange the slicer variable and also add some other codes that's already working.
Filtering the main data source then making it the pivot table data would work too I guess but I can't find a way to do that.
Can you help me?
Thanks!
Nikka
I have been trying to come up with a code that would help me filter the pivot table but with a variable different from the row/column/data fields. I tried page fields but looping .visible doesn't work and ends up with errors , especially those with continuous variable, the variable I'm looking at has decimal values.I want the same function as slicer but with a larger range of data. I tried this code,
Sub macro4()
Dim slicer As SlicerItem, i As Long
Dim pt1 As PivotTable
Set pt1 = ActiveSheet.PivotTables("PivotTable1")
pt1.ManualUpdate = True
Application.ScreenUpdating = False
Application.EnableEvents = False
With ActiveWorkbook.SlicerCaches("Slicer_ADD")
For i = 1 To .SlicerItems.Count
.SlicerItems(i).Selected = (Val(.SlicerItems(i).Value) > 100)
Next i
End With
pt1.ManualUpdate = False
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub
but it's too slow (haven't finished any run for the variable I want but it seems to be working for those with fewer values) and I still need to be able to interchange the slicer variable and also add some other codes that's already working.
Filtering the main data source then making it the pivot table data would work too I guess but I can't find a way to do that.
Can you help me?
Thanks!
Nikka