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

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
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,223,231
Messages
6,170,884
Members
452,364
Latest member
springate

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