Pivot table filtering data

nikka

New Member
Joined
Sep 10, 2014
Messages
1
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
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result

Forum statistics

Threads
1,214,982
Messages
6,122,580
Members
449,089
Latest member
Motoracer88

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