Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Macro Autofilter with conditions

Status
Not open for further replies.

neilgravir

Technical User
Jan 30, 2009
1
GB
Hi,

I'm having trouble writing a macro that does what I want.

Here is the particular part of code that is causing me problems:

Selection.AutoFilter Field:=9, Criteria1:="="
LookupVal = Range("B2")
Selection.AutoFilter Field:=8, Criteria1:=<=LookupVal, Operator:=xlAnd

I need to be able to use the value of cell B2 in LookupVal, but I also need the filter to be everything less than and equal to that (the data in question are dates). To use the <= you seem to need to have this like "<=", but then you can't use LookupVal.

Does anyone have any ideas how to acheive this?


Thanks,

Neil
 



macro record selecting the date and criteria of your choosing, and post the resulting code in Forum707. This forum does not discuss VBA code.

Skip,
[glasses]Don't let the Diatribe...
talk you to death![tongue]

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top