Help with date filter

tomleitch

Board Regular
Joined
Jan 3, 2012
Messages
189
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

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
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.

Forum statistics

Threads
1,214,374
Messages
6,119,159
Members
448,870
Latest member
max_pedreira

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