Create a list of all values from one sheet that match a cell on another - VBA

Realjoshtodd

New Member
Joined
Sep 26, 2017
Messages
34
Ok I need to build a list automatically on Sheet2 (In Column A from Row 2 down).

If I enter the data "Team 1" into A1 on Sheet2, I need it to pull anyones names from Sheet1 Column B. (Column A has the Team # they are on).

I've tried the following and have had no luck.

=IFERROR(INDEX($A$1:$A$4,SMALL(IF($B$1:$B$4=$D$1,ROW($B$1:$B$4)-ROW($B$1)+1),ROWS($B$1:$B1))),"")

Wouldn't produce anything.

I've seen a VBA code in the past that worked similar but couldn't find it to try to manipulate it to work in this case.
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Where do you want to put the names?
 
Upvote 0
What Excel version are you using?

I suggest that you update your Account details (click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version
 
Upvote 0
How about
+Fluff.xlsm
AB
1TeamName
2Team1Tom Pearce
3Team2Bill Brewer
4Team3Jan Stewer
5Team1Peter Gurney
6Team2Peter Davy
7Team3Dan'l Whiddon
8Team1Harry Hawke
9Team2Tom Cobley
Sheet1


+Fluff.xlsm
A
1Team1
2Tom Pearce
3Peter Gurney
4Harry Hawke
5 
6 
7 
8
9
10
Sheet2
Cell Formulas
RangeFormula
A2:A7A2=IFERROR(INDEX(Sheet1!$B$2:$B$9,AGGREGATE(15,6,(ROW(Sheet1!$B$2:$B$9)-ROW(Sheet1!$B$2)+1)/(Sheet1!$A$2:$A$9=$A$1),ROWS(A$2:A2))),"")
 
Upvote 0
What Excel version are you using?
If it is Excel 365 with the FILTER function, then just put this formula in A2 and the other results will automatically 'spill' down into any required cells.

Sheet1 the same as Fluff's above.

Realjoshtodd 2020-04-01 1.xlsm
ABCD
1NameTeam1
2Tom Pearce
3Peter Gurney
4Harry Hawke
5
Sheet2
Cell Formulas
RangeFormula
A2:A4A2=FILTER(Sheet1!B2:B20,Sheet1!A2:A20=D1)
Dynamic array formulas.
 
Upvote 0

Forum statistics

Threads
1,224,815
Messages
6,181,135
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