Search for a column and filter 3 or more names with wildcards

dpchheda

New Member
Joined
Oct 31, 2011
Messages
10
Hi Friends, I request your help here for a code to search for a column using column name and filter data using wildcards. ABC, PQR, and XYZ are part of the same team but no other column to identify teams and therefore they need to be searched at once from the given data.

Below code was generated by a macro. I tried to tweak it but I am not able to get my head around it and its not working as planned.

Sub Filter_DC()
Cells.Find(What:="Name", LookAt:=xlWhole).Activate
Selection.AutoFilter
ActiveSheet.Range("A1:V1000").AutoFilter Field:=14, Criteria1:=Array("*ABC*", "*PQR*", "*XYZ*"), Operator:=xlFilterValues
Cells.Find(What:="Name").Select
End Sub

Please help.
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
You can only filter with an array for exact matches, not partial matches.
How about
VBA Code:
Sub dpchheda()
   Dim Fnd As Range, Cl As Range
   
   Set Fnd = Range("1:1").Find("Name", , , xlWhole, , , False, , False)
   If Fnd Is Nothing Then Exit Sub
   With CreateObject("scripting.dictionary")
      For Each Cl In Range(Fnd, Cells(Rows.Count, Fnd.Column).End(xlUp))
         If InStr(1, Cl, "abc", vbTextCompare) > 0 Or InStr(1, Cl, "pqr", vbTextCompare) > 0 Or InStr(1, Cl, "xyz", vbTextCompare) > 0 Then
            .Item(Cl.Value) = Empty
         End If
      Next Cl
      Range("1:1").AutoFilter Fnd.Column, .Keys, xlFilterValues
   End With
End Sub
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,224,819
Messages
6,181,153
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