Results 1 to 4 of 4

AutoFilter Multiple Criteria Array

Threaded View

  1. #1
    Forum Contributor
    Join Date
    02-20-2007
    MS-Off Ver
    2003 & 2007
    Posts
    299

    AutoFilter Multiple Criteria Array

    The attached sheet contains the following code I wrote. I'm trying to set the autofilter to display only the values I load into my array (even numbers 2 - 12 on column D). The code does not debug, but it doesn't work? The autofilter gets turned on but the criteria doesn't. If i remove the "Operator:=xlFilterValues" then the last value allocated to my array, which is "12" does get set. Not sure what is wrong.

    Option Explicit
    Option Base 1
    
    Public Sub TestAutoFilterDelete()
        Dim ws As Worksheet
        Dim rng As Range
        Dim arrCriteria() As Variant
        Dim x As Integer, iteration As Integer
        iteration = 1
        For x = 2 To 12 Step 2
            ReDim Preserve arrCriteria(iteration)
            arrCriteria(iteration) = x
            iteration = iteration + 1
        Next x
        Set ws = Outputs
        Set rng = ws.Cells(1, 1).CurrentRegion
        With ws
            .AutoFilterMode = False
            With .Range(rng.Address)
                .AutoFilter
                .AutoFilter Field:=4, Criteria1:=Array(arrCriteria), Operator:=xlFilterValues        End With
        End With
    End Sub
    Attached Files Attached Files
    Last edited by erock24; 03-29-2011 at 01:27 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1