LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple criteria in autofilter BASFMark Excel Worksheet Functions 1 December 11th 08 06:38 PM
Array formula - sum with multiple criteria Atreides Excel Discussion (Misc queries) 0 April 1st 08 02:27 AM
Multiple column autofilter criteria? Possible? No Name Excel Programming 0 December 29th 04 05:43 PM
Autofilter Multiple Criteria andibevan Excel Programming 1 September 29th 04 04:45 PM
Autofilter Multiple Criteria andibevan Excel Programming 1 September 29th 04 12:52 PM


All times are GMT +1. The time now is 02:49 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"