Here is the set up (formulas in green cells):
Excel Workbook |
---|
|
---|
| A | B | C | D | E |
---|
1 | AAA | R1 | | Item | Count |
---|
2 | BBB | R2 | | AAA | 3 |
---|
3 | AAA | R3 | | | |
---|
4 | AAA | R4 | | | Return items |
---|
5 | | | | | R1 |
---|
6 | | | | | R3 |
---|
7 | | | | | R4 |
---|
8 | | | | | . |
---|
9 | | | | | . |
---|
10 | | | | | . |
---|
11 | | | | | . |
---|
|
---|
Enter this formula in cell E2:
=COUNTIF(A1:A4,D2)
Enter this formula in cell E5 with Ctrl + Shift + Enter (not just Enter) and copy down:
=IF(ROWS(E$5:E5)>$E$2,"",INDEX($B$1:$B$4,SMALL(IF($A$1:$A$4=$D$2,ROW($B$1:$B$4)-ROW($B$1)+1),ROWS(E$5:E5))))
Or to get a horizontal orientation:
Excel Workbook |
---|
|
---|
| A | B | C | D | E | F | G |
---|
1 | AAA | R1 | | Item | Count | | |
---|
2 | BBB | R2 | | AAA | 3 | | |
---|
3 | AAA | R3 | | | | | |
---|
4 | AAA | R4 | | | | | |
---|
5 | | | | | | | |
---|
6 | Returned Items | R1 | R3 | R4 | . | . | . |
---|
|
---|
Enter this formula in cell E2:
=COUNTIF(A1:A4,D2)
Enter this formula in cell B6 with Ctrl + Shift + Enter (not just Enter) and to the side:
=IF(COLUMNS($I13:I13)>$E$2,"",INDEX($B$1:$B$4,SMALL(IF($A$1:$A$4=$D$2,ROW($B$1:$B$4)-ROW($B$1)+1),COLUMNS($I13:I13))))