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
 

Some videos you may like

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off

Trevor G

Well-known Member
Joined
Jul 17, 2008
Messages
6,701
Office Version
  1. 2016
Platform
  1. Windows
Change the criteria to Date rather than "Today()"
 

Firefly2012

Well-known Member
Joined
Dec 28, 2011
Messages
3,638
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
 

Colin Legg

MrExcel MVP, Like totally RAD man
Joined
Feb 28, 2008
Messages
3,497
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
You also need to convert the date to a Long data type before including it in the criteria string.
 

Watch MrExcel Video

Forum statistics

Threads
1,122,335
Messages
5,595,573
Members
413,996
Latest member
mabelO

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