filter pivot table by last two days

avandever

Board Regular
Joined
Dec 7, 2010
Messages
83
I have a pivot table and one of the columns is named "prmdt." What I want to do is whenever I run my macro to automatically update the report, I would like it to only select today and yesterday in the "prmdt" column. In the past I believe I have ran into issues when I run the report multiple times, clearing the previous filters and re applying the new ones. Thanks.
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
hi,

One way. Create the pivot table in a new workbook using the external data option at the first step of the pivot table wizard. Follow the wizard to the end choosing the option to edit in MS Query. (Resultant worksheet can be moved into a different file if you like, for example the source data file.) Edit the SQL to suit. Say like below, or some variant. Then each time the pivot table refreshes, you only have the data of interest.

regards

Code:
SELECT *
FROM YourData
WHERE CLng([prmdt.]) IN (Date -1, Date)
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,600
Messages
6,179,834
Members
452,947
Latest member
Gerry_F

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