Google-sheets – Find the nth occurrence of variable, look at adjacent cell and organise in an array

google sheets

I have a Google spreadsheet with two arrays: The first is a list of ~100 names (in a single column) with the adjacent column being the variable (A,B,C,D,E,F,G,H,I or J). The purpose is to group people together using the variable letters.

The second is a way of sorting those names. I have 10 columns (A–J) with 10 rows each. I'd like to put the people's names into the correct column, but in consecutive rows (individual cells).

The choice of variable for each person is subject to change.

I was thinking it would be something like:

find location of nth "A", offset 1 column to find the name next to any given variable,

and just change nth from 1st – 10th for the row value, and change "A" to "B".."J" for the column.

I've been looking at functions Address, Index, Match but I just can't seem to do it.
Any help or a nudge in the right direction would be greatly appreciated.

Best Answer

To populate group A, you can just use filter(). Let's say you want group A in Col E, then in E2 (or E1) write:

=filter(A1:A, B1:B="A")

And repeat for all the other groups you want to form. Hope that helps ?