Macro autofilter problem

WaterBoy85

New Member
Joined
Nov 21, 2013
Messages
1
Hi,

I have a table of data that includes dates in L2:L6000 in the dd/mm/yy format. I am trying to run a macro that will filter the dates in column L between two variable dates. The variable dates are in cells AG18 & AG19 in the same format. I have been struggling for hours with half dozen solutions found on various forums. The closest I got was:

Range("L2:L6000").Select
Selection.AutoFilter Field:=12, Criteria1:="<=" & Sheets("When Step 2 Complete Ctrl+V").Range("AG18").Value, Operator:=xlAnd _
, Criteria2:=">=" & Sheets("When Step 2 Complete Ctrl+V").Range("AG19").Value, Operator:=xlAnd
I am pretty good at recording macros and editing them but this is a bit out of my league. Any help or suggestions would be greatly appreciated.

WaterBoy85
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Hi WaterBoy85
Lets start awith what you are filtering. If you filter Range("A2:L6000") based on Column L datat then the Field would be 12. But, if you select only column L Range("L2:L6000") to filter, then Field would be 1. Then, since you have two values for the criteria, looking for a value between the criteria you only use the operator once. Below would filter based on column L range.
Code:
Range("L2:L6000").AutoFilter 1, "<=" & Sheets("When Step 2 Complete Ctrld+V").Range("AG18"), _
xlAnd, Sheets("When Step 2 Complete Ctrl+V").Range("AG19")
 
Upvote 0

Forum statistics

Threads
1,214,940
Messages
6,122,352
Members
449,080
Latest member
Armadillos

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