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

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.

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,136,991
Messages
5,679,004
Members
419,797
Latest member
ikethegenius

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