Filter past 7 days from a column of dates

Zachary69

New Member
Joined
Jun 27, 2021
Messages
3
Office Version
  1. 2016
Platform
  1. Windows
Hi everyone, I have a data sheet that has a column of date and time in 1 min interval. Let say today is June 28, but the date in the data is April 1 to May 31. I want to analyze the data in a weekly basis based on the range of date in the column. If I filter by last week in excel I will get June 20 - June 26's data but these date is not in the data.

Is there a way to filter the past 7 days from the max date in the date column? i.e May 26 - May 31's data.

My current code is a result from a recorded macro, I am still learning, any assistance will be greatly appreciated. Thanks!

ActiveSheet.ListObjects("Master").Range.AutoFilter Field:=1, Criteria1:=5, _
Operator:=11, Criteria2:=0, SubField:=0
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
You could create a helper column as demonstrated below.

Enter the following formula in C2 and copy it down

=IF(MAX($A$2:$A$15)-A2>7,"No","Yes")

Then Filed 3 and Criteria1:= "yes"

1624849390487.png


Kind regards

saba
 
Upvote 0
Solution
You could create a helper column as demonstrated below.

Enter the following formula in C2 and copy it down

=IF(MAX($A$2:$A$15)-A2>7,"No","Yes")

Then Filed 3 and Criteria1:= "yes"

View attachment 41733

Kind regards

saba
Thanks! I see this is a viable solution. I can modify it with last 2 weeks , last 3 weeks etc as well. Appreciate it (y)
 
Upvote 0

Forum statistics

Threads
1,214,957
Messages
6,122,472
Members
449,087
Latest member
RExcelSearch

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