Apply Value Filter to Pivot table using VBA

stroffso

Board Regular
Joined
Jul 12, 2016
Messages
160
Office Version
  1. 365
Platform
  1. Windows
I have a list of properties in a Pivot table and want to have it so its like A Real Estate website where you choose between certain price points. Slicers dont really work as there are over 25 price points. I have done some research and there doesnt appear to be a kind of timeline for just values so what I am thinking is if I can have two cells, one with Minimum price (B7), one with Max Price (D7) then run some code so the value filters on PivotTable5 Column R "Sold Price" changes to be between those.

Is this possible?
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
What kind of field is "sold price"?

Code:
Sub Macro2()
' uses cells K15 and K16
Dim pt As PivotTable
Set pt = ActiveSheet.PivotTables("PivotTable2")
pt.PivotFields("category").PivotFilters.Add2 Type:=xlValueIsBetween, _
DataField:=pt.PivotFields("Sum of amount"), Value1:=[k15], Value2:=[k16]
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,615
Messages
6,120,538
Members
448,970
Latest member
kennimack

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