In a previous post I created unqiue distinct column headers (A20:C20) and then categorized adjacent cell values into each column (vba).

In this post I´ll show you how to do the same using only excel formulas.

Create unique distinct column headers

Array formula in B20:

=INDEX($B$4:$B$13, MATCH(0, COUNTIF($A$20:A20, $B$4:$B$13), 0)) + CTRL + SHIFT + ENTER.

Copy (CTRL + C) cell B20 and paste (Ctrl + V) into cells C20 and D20. See picture below.

Categorize cell values into each column

Array formula in B21:

=INDEX($C$4:$C$13, SMALL(IF($B$4:$B$13=B$20, ROW($B$4:$B$13)-MIN(ROW($B$4:$B$13))+1, ""), ROW(A1))) + CTRL + SHIFT + ENTER

Copy (CTRL + C) cell B21 and paste (Ctrl + V) into cells B21:C23 and D21:D24. See picture below.

Download excel example file
Categorize data into multiple columns (formulas).xls
(Excel 97-2003 Workbook *.xls)

Functions in this article:

MATCH(lookup_value;lookup_array; [match_type] Returns the relative position of an item in an array that matches a specified value

Returns a value or reference of the cell at the intersection of a particular row and column, in a given range

Checks whether a condition is met, and returns one value if TRUE, and another value if FALSE

ROW(reference) returns the rownumber of a reference

Counts the number of cells within a range that meet the given condition

Returns the smallest number in a set of values. Ignores logical values and text

SMALL(array,k) returns the k-th smallest row number in this data set.