Filter between today and 10 days forward

SueBK

Board Regular
Joined
Aug 12, 2014
Messages
114
I was going to ask how to do this, but I think I worked it out all by myself :-) So I thought I'd just check whether this is the most 'elegant' way of doing it?

I need to filter a range of records in my "AAA Complete Forecast" column that occur between 'today' and 10 days' time. I had some issues earlier with date formatting on filters, and found the dDate = format solution.


Code:
''Set column to filter
    Col1 = WorksheetFunction.Match("AAA Complete Forecast", Rows("1:1"), 0)
' set date format
    dDate = Format(Date, "mm/dd/yyyy")
    dDate10 = Format(Date + 10, "mm/dd/yyyy")
'Before Today
    ActiveSheet.ListObjects("Table1").Range.AutoFilter Field:=Col1, Criteria1:=">=" & dDate, Operator:=xlAnd, Criteria2:="<=" & dDate10
 
That's indeed a good approach. Rows("1:1") could be simpler as Rows(1), but other than that I wouldn't change too much.
 
Upvote 0

Forum statistics

Threads
1,226,840
Messages
6,193,270
Members
453,786
Latest member
ALMALV

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