vba to Filter Table with Dates from cell ref

Steven101

Board Regular
Joined
Oct 27, 2014
Messages
62
Hi, I need to filter a table based on 2 criteria, >= 1st date AND <= to 2nd date. Both dates are located in a cell ref in the format dd/mm/yyyy.


I have the following code

HTML:
Dim rCrit1 As Range, rCrit2 As Range

Set rCrit1 = Sheets("MI").Range("B2")
Set rCrit2 = Sheets("MI").Range("B3")

Sheets("Appeals").Select
    ActiveSheet.ListObjects("Table1").Range.AutoFilter Field:=1
    Range("Table1[[#Headers],[Date of " & Chr(10) & "Appeal]]").Select
    ActiveSheet.ListObjects("Table1").Range.AutoFilter Field:=1, Criteria1:= _
        ">=" & CDate(rCrit1.Value), Operator:=xlAnd, Criteria2:="<=" & CDate(rCrit2.Value)


The issue is that when I check the filter, it's putting the filtered dates in the format mm/dd/yyyy

I've tried changing the format of the 2 cells to mm/dd/yyyy but this doesn't work.

Any help would be appreciated.

Thanks
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Hi

I would use advanced filter. The table column being filtered has the header "dates".

ZzOWbA5.png


Code:
Sub AdvFilter()
Dim t As ListObject
Set t = ActiveSheet.ListObjects(1)
t.Range.AdvancedFilter xlFilterInPlace, [a1:b2], , 0
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,522
Messages
6,120,020
Members
448,938
Latest member
Aaliya13

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