AutoFilter using wildcards in Array seems limited to two fields.

stchln

New Member
Joined
Sep 2, 2013
Messages
1
Hello

I am wondering if the AutoFilter when used with Array of fields using wildcards has some limitation. In example below, if I use two entries in my AutoFilter, the filtering works fine but if I use a third entry, the "4-*" here, the filtering is not working anymore.

I suspect Excel is limiting to two entries as when using textual filter from the menu.

Could someone confirm my statement ?

ColumnA
1-one
1-oneb
2-two
2-twob
3-three
3-threeb
4-four

<colgroup><col style="width:66pt" width="88"> </colgroup><tbody>
</tbody>


Sub test()

Range("A1").Select
Selection.AutoFilter Field:=1, Criteria1:=Array("1-*", "2-*", "4-*"), _
Operator:=xlFilterValues

End Sub
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
I am not an expert.l I am also having problem, with wild card more than two. alternative method (macro test) is suggested.


data is like this

Excel Workbook
A
1hdng
21-one
31-oneb
42-two
52-twob
63-three
73-threeb
84-four
Sheet1



try this macro" test"

after you have manipulated the data post autofilter then do not fail to run""undo"

Code:
Sub test()
    Dim r As Range, c As Range, i As Integer, j As Integer
    Dim ttext(1 To 3) As String
    ttext(1) = "1"
    ttext(2) = "2"
    ttext(3) = "3"
    Undo
    j = Range("A2").End(xlDown).Row
    For i = 2 To j


        Set r = Cells(i, 1)
        If Left(r, 1) = ttext(1) Or Left(r, 1) = ttext(2) Or Left(r, 1) = ttext(3) Then
            r.EntireRow.Hidden = False
        Else


            r.EntireRow.Hidden = True
        End If
    Next i
    MsgBox "macro over. after your work is over run undo"
End Sub
Code:
Sub Undo()
    ActiveSheet.Cells.EntireRow.Hidden = False


End Sub
 
Upvote 0
It looks like it, yes. I also tried to do it by using Criteria2 (with xlOr operator), but then it only uses the last item in the array coupled with the other criteria, so no real progress.

But without wildcards you can use more elements in the array (using only Crieria1) so if you can populate the array in runtime that will do the trick. An example can be found here:
Filter 1 Column With Multiple Criteria
 
Upvote 0
I now suppose it can be done by advanced filter instead of autofilter

see tis below criteria is in H1:H4

in the advanced filter window
list range A1:a8
criteria range is H1:H4

check "copy to another location"
copyt
to: K1
uncheck "unique values only"



reult of filter is in col. K


you can get it either in advanced filter or macro whichever you are comfortable with

Sheet1

*ABCDEFGHIJK
1hdng******hdng**hdng
21-one******1***1-one
31-oneb******2***1-oneb
42-two******3***2-two
52-twob*********2-twob
63-three*********3-three
73-threeb*********3-threeb
84-four**********

<colgroup><col style="font-weight:bold; width:30px; "><col style="width:64px;"><col style="width:64px;"><col style="width:64px;"><col style="width:64px;"><col style="width:64px;"><col style="width:64px;"><col style="width:64px;"><col style="width:64px;"><col style="width:64px;"><col style="width:64px;"><col style="width:64px;"></colgroup><tbody>
</tbody>


Excel tables to the web >> Excel Jeanie HTML 4
 
Upvote 0

Forum statistics

Threads
1,213,546
Messages
6,114,256
Members
448,557
Latest member
richa mishra

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top