Macro Autofilter by today date?

meetz

New Member
Joined
Dec 29, 2015
Messages
7
How to use today formula in below coding to get all the records before today's date?

Code:
[COLOR=#333333]ActiveSheet.Range("$A$2:$M$377").AutoFilter Field:=7, Criteria1:=[/COLOR]"50"[COLOR=#333333]
[/COLOR][COLOR=#333333]        "<29.1.2011", Operator:=xlAnd[/COLOR]
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Hi,

This piece of code shows all dates before today.

Code:
ActiveSheet.Range([COLOR=#333333]("$A$2:$M$377").A[/COLOR]utoFilter Field:=7, Criteria1:= "<" & Format(Now(), "mm/dd/yyyy")
 
Upvote 0
Thank you for the answer.

My question is if i want for today's date and every day i have to work on. So on daily bases i don't want to change date in coding.

Hi,

This piece of code shows all dates before today.

Code:
ActiveSheet.Range([COLOR=#333333]("$A$2:$M$377").A[/COLOR]utoFilter Field:=7, Criteria1:= "<" & Format(Now(), "mm/dd/yyyy")
 
Upvote 0
The "Now()" part returns the date of the day you run the code on. So tomorrow it will filter before tomorrow.
It seems that this is the way you want it to work?
 
Upvote 0
The "Now()" part returns the date of the day you run the code on. So tomorrow it will filter before tomorrow.
Note that Now() actually returns date AND time (you are dropping the time part with the Format function).
If you want just the date portion, you could just use Date().
 
Upvote 0
Ok Joe4

Thank you for the same.

Note that Now() actually returns date AND time (you are dropping the time part with the Format function).
If you want just the date portion, you could just use Date().
 
Upvote 0

Forum statistics

Threads
1,215,606
Messages
6,125,803
Members
449,261
Latest member
Rachel812321

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