Autofilter Questions

JRHartley

New Member
Joined
May 22, 2012
Messages
7
Hi all,

I'm trying to make a spreadsheet for my to do list. I'd like a few command buttons to filter this in a number of ways - tasks due today, overdue tasks, tasks due in next week etc, by context (work / personal) etc.

I am no good at coding so have tried to record a number of macros, but the filters don't behave as expected when run as a macro. Currently I have

Code:
Sub FilterTaskByDate_Today()
'
' FilterTaskByDate_Today Macro
'


'
     ActiveSheet.Range("$A$3:$G$300").AutoFilter Field:=5, Criteria1:="Today()", _
        Operator:=xlAnd
End Sub

Can anyone see why this might not be behaving?

Full spreadsheet is here: https://dl.dropbox.com/u/1337635/ToDo.xlsm

Thanks in advance for any help!

Cheers
Jon
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Change the criteria to Date rather than "Today()"
 
Upvote 0
Jon

because of the vagaries of the way autofilter works with dates, you would probably need to change the line (using Trevor G's suggestion) to:

Code:
ActiveSheet.Range("$A$3:$G$300").AutoFilter Field:=5, Criteria1:=">=" & Date, _
        Operator:=xlAnd, Criteria2:="<=" & Date
 
Upvote 0
You also need to convert the date to a Long data type before including it in the criteria string.
 
Upvote 0

Forum statistics

Threads
1,213,513
Messages
6,114,064
Members
448,545
Latest member
kj9

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