Filter column using criteria from a userform

E

Eileen

I would like to filter a column based on criteria entered
into a userform. I've got this code so far using actual
dates:
Selection.AutoFilter Field:=51, Criteria1:=">=01/06/2003",
Operator:= _
xlAnd, Criteria2:="<=30/10/2003"

BUT, I want to substitute the dates for variables that
come from a date picker on the userform, ie >=variablename
I've tried:
Criteria1:= >= variablename
Criteria1:= ">=" variablename
Criteria1:= ">=variablename" - this picks up the words,
not the variable

But none of them work - what syntax do I use?

Please help.
Thanks
 
D

Debra Dalgleish

Use an ampersand to join the operator and variable:

Selection.AutoFilter Field:=51, Criteria1:=">=" & Variable1, _
Operator:=xlAnd, Criteria2:="<=" & Variable2
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top