Autofilter equal to and between two values

stelladave

New Member
Joined
Jul 19, 2012
Messages
7
Hello,

I am having an issue with an Autofilter in VBA. See below for the current code. The desired result is to specify two dates and filter between those dates but also include the dates as well. Currently the filter is not returning the EDate values (it is returning the Sdate values). Also, I need to be able to return the date if Sdate and Edate are equal to eachother (currently not working).

Sdate = Sheet1.Range("C1").Value
EDate = Sheet1.Range("G1").Value


Workbooks.Open Filename:=Pth & "\Phone.csv"
SrsFnm = ActiveWorkbook.Name
Workbooks(SrsFnm).Activate
Sheets(1).AutoFilterMode = False
Sheets(1).Range("A:BB").AutoFilter
Sheets(1).Range("A:BB").AutoFilter Field:=11, Criteria1:=">=" & Sdate, Operator:=xlAnd, Criteria2:="<=" & EDate

Any help would be much appreciated.

Thanks,
Dave
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple

Forum statistics

Threads
1,214,919
Messages
6,122,260
Members
449,075
Latest member
staticfluids

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