Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Autofilter multiple criteria using array
Is it possible to autofilter multiple criteria using an array? I'm trying
to do something like this, but I don't know how to check each element of the array. Really, all I'm trying to do is pull certain sets of data (determined by the data found in column k) and copy the entire rows to a new worksheet. I've used autofilter to do this in the past, but never to copy multiple criteria to one sheet. Sub filterArray() Dim r As Range Dim v As Variant ' pitiful first attempt v = Array("cat", "dog", "mouse") ' I'd really like to set the array equal to data in a named range. With Worksheets("Tester") Set r = .Range(.Range("k2"), .Range("k" & .Rows.count).End(xlUp)) .Columns("K:K").AutoFilter Field:=1, Criteria1:=v(0) Set r = r.SpecialCells(xlCellTypeVisible) .Columns("K:K").AutoFilter Field:=1, Criteria1:=v(1) Set r = r + r.SpecialCells(xlCellTypeVisible) .Columns("K:K").AutoFilter Field:=1, Criteria1:=v(2) '** The number of actual elements will vary. Set r = r + r.SpecialCells(xlCellTypeVisible) r.EntireRow.Copy Destination:=Worksheets("CopyToSheet").Range("a1") ..AutoFilterMode = False End With End Sub I hope this makes sense! Any suggestions much appreciated! |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Multiple criteria in autofilter | Excel Worksheet Functions | |||
Array formula - sum with multiple criteria | Excel Discussion (Misc queries) | |||
Multiple column autofilter criteria? Possible? | Excel Programming | |||
Autofilter Multiple Criteria | Excel Programming | |||
Autofilter Multiple Criteria | Excel Programming |