I've got some code that I'm trying to use to filter date ranges by which looks at a 'settings' cell on another sheet to determine a date range to filter.
For some reason it's not returning anything - but if I go in the date filter on that column and look at custom filter - then it's there
The weird thing is that I have the same code on another workbook and it works of - obviously I've changed the sheet names over
Any help or pointers much appreciated
Thanks
Tom
For some reason it's not returning anything - but if I go in the date filter on that column and look at custom filter - then it's there
Code:
On Error Resume NextSheets("PROD").ShowAllData
On Error GoTo 0
Fstart = CDate(ThisWorkbook.Sheets("SETTINGS").Range("L4").Value)
If Sheets("SETTINGS").Range("E2").Value = "0" Then Sheets("PROD").Range("$A2:AR5010").AutoFilter Field:=SCHEDST, Criteria1:=">=" & Fstart, Operator:=xlAnd, Criteria2:="<" & (Fstart + 14)
If Sheets("SETTINGS").Range("E2").Value = "1" Then Sheets("PROD").Range("$A2:AR5010").AutoFilter Field:=SCHEDST, Criteria1:=">=" & (Fstart + 14), Operator:=xlAnd, Criteria2:="<" & (Fstart + 28)
If Sheets("SETTINGS").Range("E2").Value = "3" Then Sheets("PROD").Range("$A2:AR5010").AutoFilter Field:=SCHEDST, Criteria1:=">=" & (Fstart + 28), Operator:=xlAnd, Criteria2:="<" & (Fstart + 42)
If Sheets("SETTINGS").Range("E2").Value = "5" Then Sheets("PROD").Range("$A2:AR5010").AutoFilter Field:=SCHEDST, Criteria1:=">=" & (Fstart + 42), Operator:=xlAnd, Criteria2:="<" & (Fstart + 56)
If Sheets("SETTINGS").Range("E2").Value = "16" Then Sheets("PROD").Range("$A2:AR5010").AutoFilter Field:=SCHEDST, Criteria1:=">=" & Fstart, Operator:=xlAnd, Criteria2:="<" & (Fstart + 112)
If Sheets("SETTINGS").Range("E2").Value = "A" Then Sheets("PROD").Range("$A2:AR5010").AutoFilter Field:=SCHEDST, Criteria1:="<>" & Fstart
The weird thing is that I have the same code on another workbook and it works of - obviously I've changed the sheet names over
Any help or pointers much appreciated
Thanks
Tom