Applying auto filter to A8 on existing code(Wild card unable to use in autofilter array answered by RickXL)

yun_h

New Member
Joined
Jul 12, 2023
Messages
1
Office Version
  1. 365
  2. 2013
  3. 2010
Platform
  1. Windows
Hi Experts,

I found below code in forums while I was looking for way to use wild card to filter. Currently, it works fine but I want to switch the filtered row to A8 instead of A1.

With my lack of knowledge, I thought I could change .Columns("A:A") to .Columns("A8:A"). But I get debug.. is there anyway that I can change the filter row without changing below code too much?

Thanks in advance !


VBA Code:
Sub myFilter()
    Dim dic     As Object
    Dim eleData As Variant
    Dim eleCrit As Variant
    Dim arrData As Variant
    Dim vTst    As Variant
  
    Set dic = CreateObject("Scripting.Dictionary")
    vTst = Array("*ABC*", "*DEF*", "*GHI*", "*JKLM*", "*nn*")
    With ActiveSheet
        .AutoFilterMode = False
        arrData = .Range("A1:A" & .Cells(.Rows.Count, "A").End(xlUp).Row)
        For Each eleCrit In vTst
            For Each eleData In arrData
                If eleData Like eleCrit Then dic(eleData) = vbNullString
            Next
        Next
        .Columns("A:A").AutoFilter Field:=1, Criteria1:=dic.Keys, Operator:=xlFilterValues
    End With
End Sub
 
Last edited by a moderator:

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Please post a copy of your worksheet using the XL2BB - Excel Range to BBCode or alternatively, share you file via Google Drive, Dropbox or similar file sharing platform. You can easily disguise any data that may be sensitive.
 
Upvote 0

Forum statistics

Threads
1,224,817
Messages
6,181,149
Members
453,021
Latest member
Justyna P

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