AutoFilter Macro Based On 3 Criteria

milwphil

Board Regular
Joined
Aug 1, 2010
Messages
120
Good morning!

I have a macro that allows the user to AutoFilter by Name, Start Date and End Date.

I have it working; however, now I need it to be able to provide everyone in the list in the criteria, but still filter between start and end date.

Here is the code I'm using:
Code:
Sub Filter()
Dim DateStart As Date
Dim DateEnd As Date
Dim Name As String
DateStart = [H3].Value
DateEnd = [I3].Value
Name = [G3].Value
' Set the filter
Range("A5:IV5").Select
    Selection.AutoFilter
 
    Selection.AutoFilter Field:=2, Criteria1:=Name    
    Selection.AutoFilter Field:=21, Criteria1:= _
        ">=" & DateStart, Operator:=xlAnd, Criteria2:="<=" & DateEnd
    Range("U5").Select
End Sub

In short, I'd like to let the user to be able to select "ALL" in cell G3 (in the worksheet) and if "ALL" defer to only the start and end date.

ANY HELP WOULD BE GREATLY APPRECIATED!

Thanks,
Phil
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.

milwphil

Board Regular
Joined
Aug 1, 2010
Messages
120
Nevermind...I got it w/simple if statements. Thanks to all that considered answering!
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,301
Messages
5,836,493
Members
430,436
Latest member
fefenouil

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