Filter Greater than 2 working days out

nniedzielski

Well-known Member
Joined
Jan 8, 2016
Messages
590
Office Version
  1. 2019
Platform
  1. Windows
I am trying to build a macro that will filter all dates in column G that are more than 2 business days out, so weekends removed. I tried recording one, but just got this:
VBA Code:
Selection.Range("$A$1:$AT$937").AutoFilter Field:=7, Criteria1:= _
        ">6/11/2021", Operator:=xlAnd
which is great for today, but will obviously not work tomorrow. How can I set the logic to always grab any dates further out than 2 working days?

2nd Note, I also need any dates in the past as well, they are super rare, but need to grab those too.

thanks,
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
if
6/11/2021
is todays date then try the following:
VBA Code:
Selection.Range("$A$1:$AT$937").AutoFilter Field:=7, Criteria1:= ">" & Date, Operator:=xlAnd, Criteria1:= "<=" & Date + 2

This will filter out dates greater then today and less then equal to next 2 days, only.

for your second query try
VBA Code:
Selection.Range("$A$1:$AT$937").AutoFilter Field:=7, Criteria1:= "<" & Date

This will filter out all dates less then today's date.

hth....
 
Upvote 0

Forum statistics

Threads
1,214,528
Messages
6,120,065
Members
448,941
Latest member
AlphaRino

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