Macro to filter a column with multiple names

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
3,195
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Hi Everyone,
I thought this would be easy but i having problems,

All i want to do is filter Column D so it only shows me these names
Tom
Robin
Dave
Sue
Lenny
Barry

can someone please give me the vba code to do this

Thanks
Tony
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
VBA Code:
Sub FilterNames()
nFilter = Array("Tom", "Robin", "Dave", "Sue", "Lenny", "Barry")
Range("D1:D" & Range("D" & Rows.Count).End(xlUp).Row).AutoFilter 1, nFilter, xlFilterValues
End Sub
 
Upvote 0
Hi Again
Hope all is well

VBA Code:
    If Sheets("Sheet1").FilterMode Then Sheets("Sheet1").ShowAllData
    Sheets("Sheet1").Range("$D$1:$D$32").AutoFilter Field:=1, Criteria1:=Array("Tom", "Robin", "Dave", "Sue", "Lenny", "Barry"), Operator:=xlFilterValues
 
Upvote 0
Solution
Hello Efan, I feel i would be lost without you this week :)
thank you again for a great bit of code,

A big thank you to Irobbo as well, very much apreciated :)
Tony
 
Upvote 0

Forum statistics

Threads
1,215,452
Messages
6,124,914
Members
449,195
Latest member
Stevenciu

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