Passing a named varaible to Excel's Autofilter

J

Jeff Glock

Does anyone know how to use a variable name in these sorts
of statements?

Selection.AutoFilter field:=14, Criteria1:="<>*R*",
Operator:=xlOr, _
' Criteria2:="<>*H*"

and

Selection.AutoFilter field:=14, Criteria1:="=(Blank)",
Operator:=xlAnd

Work for finding records that contain blanks or do not
contain "R" or "H". However, given a variable for a date
named "FWDATE", the statement;

Selection.AutoFilter field:=10,Criteria1:>"FWDATE",
Operator:=xlAnd

does not work.

Any help would be appreciated.
 
T

Tom Ogilvy

Dim FWDATE as DATE
FWDATE = DateValue("10/25/2003")
Selection.AutoFilter field:=10,Criteria1:=">" & clng(FWDATE"), _
Operator:=xlAnd

Not sure what you mean by a date named FWDATE. I will assume FWDATE is a
variable of type DATE that has been assigned a value.
 

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