Auto filter based on yesterdays date

anichols

Board Regular
Joined
Mar 11, 2021
Messages
87
Office Version
  1. 365
Platform
  1. Windows
Hello all,

I have an autofilter that I am trying to have match yesterdays date, and I am struggling to make it work. I am trying to show all values that do not match yesterdays date so I can delete all those rows.

VBA Code:
    Selection.AutoFilter
    ActiveSheet.Range("AU1:AU" & Lastrow).AutoFilter Field:=47, Criteria1:="<>Format(Date - 1, "m/d/yyyy")", Operator:=xlFilterValues
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
VBA Code:
Sub FiltrDate()
Dim MyVal As Date

MyVal = Date

ActiveSheet.Range("A1:A20").AutoFilter 1, ">=" & CDbl(MyVal)

End Sub

Change range to match your needs.
 
Upvote 0

Forum statistics

Threads
1,215,575
Messages
6,125,631
Members
449,241
Latest member
NoniJ

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