First of all, the groups must have the same size of Data (just in case the row has just one number). So Group 1 must be from T to AK.
On cell T2 enter the formula:
=IFERROR(INDEX($A$2:$R$2,SMALL(IF($A$2:$R$2=1,COLUMN($A$2:$R$2)),COLUMN(A:A))),"")
Type the formula and press Ctrl+Shift+Enter to enter an array formula. Then, when copying and pasting on columns U to AK will show on Group1 all the ocurrences of the 1.
Some tips to improve it:
- If you put in cell T1 just the number 1 and then custom format it to show
"Group " 0
, then you can change the 1 on the formula to the address T1. Then, when copying it to the other groups, the formula should adjust to the other numbers (you must put 1 to every column from T to AK, but show just one of them and, form columns AM to BD, there should be the number 2 and so on).
- If your excel is 2010 or older, then you don't have the
IFERROR()
function. The workaround is to use an IF()
and an ISERROR()
: IF(ISERROR(...),"",(...))
. The (...)
is the formula on the first argument of the IFERROR()
.
- To copy the formula to the other rows, you can change the INDEX function to return a row and column. To only difference then is that the returning row is the row of the cell and the column is the formula
(...)
.