I hope someone can help me. My problem is two-fold:
1. Using two drop-down boxes on a FORM, I want to be able to firstly, select a start DATE (e.g. 22/01/2009) from one box, and an end DATE (e.g. 22/03/2009) from the other box, where both drop-down box fields reference a column listing of DATES on a worksheet, which in turn contains multiples of the same DATES i.e. the dates in the column listing are not unique so I need them filtered down to one of each (i.e. not displaying any duplicates) for selection from the drop-down boxes.
When saved, the FORMS drop-down box DATE selections then get copied to two different cells on another worksheet (this I can already do)
2. I need to then have the two DATES contained in the cells in the worksheet (that were copied from the above FORM selections), referenced in an AutoFilter procedure in a macro.
This how the macro entry would look if the two dates were static and if I filtered them manually using the Custom function of AutoFilter directly in the worksheet:
' Selection.AutoFilter Field:=2, Criteria1:=">=22/01/2009", Operator:=xlAnd _
' , Criteria2:="<=22/03/2009"
However, my dates will be variables (based on the selections I want to make from my drop-down boxes) so I have tried the following but neither work (and neither allows me to take into account the “>=” and “<=” prefixes):
TW = Worksheets("Report").Range("B4")
TW1 = Worksheets("Report").Range("B5")
Selection.AutoFilter Field:=2, Criteria1:=TW, Operator:=xlAnd _
, Criteria2:=TW1
or
Selection.AutoFilter Field:=2, Criteria1:=ThisWorkbook.Worksheets("Report").Range("B4").Value, Operator:=xlAnd _
, Criteria2:=ThisWorkbook.Worksheets("Report").Range("B5").Value
When run, the results of the macro AutoFilter procedure “should” then filter to display all column entries (including all DATE duplicates) that are equal to and greater then/equal to and less than, the two DATES originally selected in the two drop-down boxes on the FORM.
1. Using two drop-down boxes on a FORM, I want to be able to firstly, select a start DATE (e.g. 22/01/2009) from one box, and an end DATE (e.g. 22/03/2009) from the other box, where both drop-down box fields reference a column listing of DATES on a worksheet, which in turn contains multiples of the same DATES i.e. the dates in the column listing are not unique so I need them filtered down to one of each (i.e. not displaying any duplicates) for selection from the drop-down boxes.
When saved, the FORMS drop-down box DATE selections then get copied to two different cells on another worksheet (this I can already do)
2. I need to then have the two DATES contained in the cells in the worksheet (that were copied from the above FORM selections), referenced in an AutoFilter procedure in a macro.
This how the macro entry would look if the two dates were static and if I filtered them manually using the Custom function of AutoFilter directly in the worksheet:
' Selection.AutoFilter Field:=2, Criteria1:=">=22/01/2009", Operator:=xlAnd _
' , Criteria2:="<=22/03/2009"
However, my dates will be variables (based on the selections I want to make from my drop-down boxes) so I have tried the following but neither work (and neither allows me to take into account the “>=” and “<=” prefixes):
TW = Worksheets("Report").Range("B4")
TW1 = Worksheets("Report").Range("B5")
Selection.AutoFilter Field:=2, Criteria1:=TW, Operator:=xlAnd _
, Criteria2:=TW1
or
Selection.AutoFilter Field:=2, Criteria1:=ThisWorkbook.Worksheets("Report").Range("B4").Value, Operator:=xlAnd _
, Criteria2:=ThisWorkbook.Worksheets("Report").Range("B5").Value
When run, the results of the macro AutoFilter procedure “should” then filter to display all column entries (including all DATE duplicates) that are equal to and greater then/equal to and less than, the two DATES originally selected in the two drop-down boxes on the FORM.