neilgravir
Technical User
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
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