Dynamic Pivot: Value Filter Between

AlwaysNeedExcelHelp

New Member
Joined
Sep 24, 2019
Messages
6
Hello,

I am looking to use inputs in my excel to alter a pivot table to show only the values between the min and the max inputs. I have the below code but the highlight part is where I fail. How can I reference the values? It produces a "Unable to get the PivotTables property of the Worksheet class" error.

Thank you,


Sub EditRange()


Dim a
Dim b



a = Range("b3").Value
b = Range("c3").Value


ActiveSheet.PivotTables("RangePivot").PivotFields("Office").ClearAllFilters
ActiveSheet.PivotTables("RangePivot").PivotFields("Office").PivotFilters.Add2 _
Type:=xlValueIsBetween, DataField:=ActiveSheet.PivotTables("PivotTable1"). _
PivotFields("Sum of Net Revenues"), Value1:=a, Value2:=b






End Sub
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.

Forum statistics

Threads
1,223,981
Messages
6,175,768
Members
452,668
Latest member
mrider123

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