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
Bookmarks