Set Auto Filtering multiple wildcards captured from Table Array

pommoz313

New Member
Joined
Nov 2, 2018
Messages
3
Office Version
  1. 365
Platform
  1. Windows
I'm trying to use a Dictionary to populate a multiple wildcard AutoFilter for a which is captured from a table array. The capture seems to work fine however when it gets to applying the AutoFilter I get a Run-Time 448 'Named argument not found' error.

The data to be filtered is on a sheet called "FOLIOS" and is populated with headers from A1:P1 (with the filter to be applied to the data in column P. Column P contains various email addresses and I'm trying to filter them based on the domain names stored in tblOTA located on the "HDATA" sheet.

Any help would be very appreciated (Excel 365)

The table containing the criteria is named tblOTA (below) and already has the wildcard prefix "*" stored before the domain name:
tblOTA
*@central.com
*@guest.com
*@test.com


Here is the code:
Rich (BB code):
Sub test()
'
' TEST Macro
'

'
    Dim WB As Workbook: Set WB = ThisWorkbook
    Dim aARRs As Variant
    Dim OTA As ListObject
    Dim dVALs As Object
    Dim a As Long
   
   
    Set OTA = Sheets("HDATA").ListObjects("tblOTA")
   
    Set dVALs = CreateObject("Scripting.Dictionary")
    dVALs.CompareMode = vbTextCompare

    With Sheets("FOLIOS")
        If .AutoFilterMode Then .AutoFilterMode = False
       
           'Create Array List from Table
            aARRs = OTA.DataBodyRange
            For a = LBound(aARRs, 1) + 1 To UBound(aARRs, 1)
                    dVALs.Add Key:=aARRs(a, 1), Item:=aARRs(a, 1)
            Next a
   
   
    'test the array
    'Dim k As Variant
    'For Each k In dVALs.Keys
        'Debug.Print k & " - " & dVALs.Item(k)
    'Next k
   
    'filter on column P if dictionary keys exist -- (Run time error occurs here)
        If CBool(dVALs.Count) Then _
                .AutoFilter Field:=16, Criteria1:=dVALs.keys, _
                          Operator:=xlFilterValues, VisibleDropDown:=False
   
        If .AutoFilterMode Then .AutoFilterMode = False
    End With

    dVALs.RemoveAll: Set dVALs = Nothing
End Sub
 
Last edited by a moderator:

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
I have managed to put a work around in that was very simple in the end really. I used a helper-column on the end and added a formula to return TRUE if any of emails in Column P contained the domains listed in tblOTA then filtered on this. The formula "=OR(INDEX(COUNTIF([@Email],"*"&tblOTA[#Data]&"*"),0))"
 
Upvote 0
Solution
Of course, if anyone wants to provide the code to use a Dictionary to populate the AutoFilter Criteria then I would be grateful.
 
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,264
Members
452,627
Latest member
KitkatToby

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