Hi All,

I'm completely new to VBA so please bear with me. I've been reading various sources for the past few hours on how to autofilter a table based on 2 variable dates. I've tried various different scripts but can't get it to work. Please could someone show me what I'm doing wrong:

Background:
I have a simple table of data with column 1 being a date input - the column headers are at B8:G8.
At cell K5 I have a start date which is user entered
At cell J5 I have an end date which is user entered
I wish to filter the table for entries between these 2 dates.

At the minute my code reads as:

Sub FilterJB()

Dim DateStart As Date
Dim DateEnd As Date

DateStart = [K5].Value
DateEnd = [L5].Value

' Set the filter

Range("B8:G8").Select
Selection.AutoFilter

ActiveSheet.Range("$B$8:$G$5005").AutoFilter Field:=2, Criteria1:="J5", Operator:=xlAnd
ActiveSheet.Range("$B$8:$G$5005").AutoFilter Field:=1, Criteria1:=">=" & DateStart, Operator:=xlAnd, Criteria2:="<=" & DateEnd


End Sub


Any help would be much appreciated.

Best wishes

Joe