Results 1 to 2 of 2

How to restore autofilter Criteria1 that is an array of strings

Threaded View

  1. #1
    Registered User
    Join Date
    01-12-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    1

    How to restore autofilter Criteria1 that is an array of strings

    I need to restore that state of my autofilter environment after processing some data. I am having trouble restoring a state of an autofilter that is an array of strings. When I restore the array only the last element in the array is saved. The following is my code.

    CurrentFilterRange = FilterObject.RangeAddress
      For i = 1 To UBound(FilterObject.Criteria1)
        ' Check to see if this item is being filtered
        If Not IsEmpty(FilterObject.Criteria1(i)) Then
          If FilterObject.Operator(i) <> "" Then
            Wks.Range(CurrentFilterRange).AutoFilter field:=i, Criteria1:=FilterObject.Criteria1(i), Operator:=FilterObject.Operator(i), Criteria2:=FilterObject.Criteria2(i)
          Else
            objType = TypeName(FilterObject.Criteria1(i))
            ' Check if the original criteria was a single value or an array of values
            If objType = "String" Then
              Wks.Range(CurrentFilterRange).AutoFilter field:=i, Criteria1:=FilterObject.Criteria1(i)
            Else
              Wks.Range(CurrentFilterRange).AutoFilter field:=i, Criteria1:=FilterObject.Criteria1(i), Operator:=xlFilterValues
    
              'Next
            End If
          End If
        End If
      Next
    Last edited by arlu1201; 01-13-2013 at 08:49 AM. Reason: Discovered my solution

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