Autofilter

millhouse123

Active Member
Joined
Aug 22, 2006
Messages
335
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

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
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!
 
Upvote 0

Forum statistics

Threads
1,214,639
Messages
6,120,679
Members
448,977
Latest member
dbonilla0331

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