Jvalades

New Member
Joined
Jul 28, 2016
Messages
40
Hellloooo Friends.. Can someone help me debug my Advanced filter.

My end goal is to hide all rows that do no have "ABCD-201,ABCD-202,ABDC-203" in column A.


Code:
 'Start my filters
      
    'creating a Advanced filter to find ABCD
    With Sheets(2)
    
    .Range("AR1").NumberFormat = "General"
        'Insert values of interest in cells AP1
        .Range("AP1").Value = "ABCD"
        
    'Create named range MyList
    .Names.Add Name:="MyList", RefersTo:="='SO'!$AP$1"
    
    'Put a header in AQ1
    .Range("AQ1").Value = "MyList"
     
     'Create the criteria range in range AR1 using a formula
        .Range("AR1").Formula = "=NOT(OR(INDEX(ISNUMBER(SEARCH(MyList,A2)),0)))"
        
        'Apply advanced filter in data range
        .Range("$A$1:$A$" & .Cells(.Rows.count, "A").End(xlUp).Row). _
            AdvancedFilter Action:=xlFilterInPlace, criteriarange:=.Range("AR1"), _
            Unique:=False
    End With
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
See if this does what you are looking for

Code:
Sub aTest()
    
    With Sheets(2)
        'Put a header in AP1
        .Range("AP1") = "Mylist"
        'Insert values of interest in cells AP2, AP3,...
        .Range("AP2").Value = "ABCD-201"
        .Range("AP3").Value = "ABCD-202"
        .Range("AP4").Value = "ABCD-203"
        
        'Create named range MyList
        .Range("AP2:AP4").Name = "Mylist"
     
        If .FilterMode Then .ShowAllData
        
        'Create the criteria range in range AR1:AR2 using a formula
        'leave blank the cell above the formula
        .Range("AR1") = ""
        'insert the formula in AR2 - assumes data beginning in row 2, header in row 1
        .Range("AR2").Formula = "=ISNUMBER(MATCH(A2,MyList,0))"
        
        'Apply advanced filter in data range
        .Range("$A$1:$A$" & .Cells(.Rows.Count, "A").End(xlUp).Row). _
            AdvancedFilter Action:=xlFilterInPlace, criteriarange:=.Range("AR1:AR2"), _
            Unique:=False
    End With
End Sub

M.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,551
Members
449,088
Latest member
davidcom

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