Autofilter

millhouse123

Active Member
Joined
Aug 22, 2006
Messages
334
I have this line of code that filter on 2 criteria. I currently have one of the criteria set as the date and it is hard coded as 8/22/2006. This date changes daily.

What I want todo is replace the date with a variable but when I do it gives me an error.

Basically I have Date = 9/19/2006 or whatever date it might be. What I want to do is put the variable in below instead of the hard coded date. How can I do this.

Thanks

Selection.AutoFilter Field:=8, Criteria1:="DONE"
Range("W5").Select
Selection.AutoFilter Field:=23, Criteria1:="> 8/22/2006", Operator:=xlAnd
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand

Tazguy37

MrExcel MVP
Joined
May 28, 2004
Messages
4,237
Try this, which should use the current date:

Code:
Selection.AutoFilter Field:=8, Criteria1:="DONE" 
Range("W5")..AutoFilter Field:=23, Criteria1:=">" & Date, Operator:=xlAnd

I'll check back to see if this works or not. This PC (not mine) has a trial version of Office :x

HTH

Hi to all from Rocky Mountain country! Good to be back!
 

Forum statistics

Threads
1,171,463
Messages
5,875,660
Members
433,146
Latest member
MinhTrang

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
Top