PDA

View Full Version : Using a variable to as criteria in autofilter



Wand
04-26-2013, 04:32 AM
Hi, hope someone out there can help.
I am trying to run the code below but keep getting a runtime error code 1004 - Application-defined or object-defined error.

ActiveSheet.Range("$A$:$Q").AutoFilter Field:=15, Criteria1:= _
MyCell, Operator:=xlFilterValues

I declared MyCell as a Range and want to use it as a filter criteria in my data A$:Q$.

Any help will be much appreciated.

snb
04-26-2013, 04:57 AM
with ActiveSheet.usedrange.resize(,17)
.AutoFilter 15, MyCell.value
end with

Wand
04-26-2013, 06:26 AM
Works perfect.

Many thanks snb, made my day!

snb
04-26-2013, 06:43 AM
Too much honour, your Honour. ;)