Group arbitrary text values in Excel
This tutorial shows how to Group arbitrary text values in Excel using the example below;
Formula
=VLOOKUP(value,table,column,0)
Explanation
IF you want to group or classify data based on arbitrary text values, you can use VLOOKUP instead of a long series of nested IF statements.
The trick is to build a custom table that will map values to all the groups you need.
In the example shown, the formula in F5 is:
=VLOOKUP(E5,key,2,0)
How this formula works
This formula uses the value in cell E5 for a lookup value, the named range “key” (H5:I9) for the lookup table, 2 to indicate “2nd column”, and 0 as the last argument indicate exact match. You can also use FALSE instead of zero if you like.
VLOOKUP simply looks up the value and returns the group name from the 2nd column in the table. Both columns in the table can contain any values that you need, and the table doesn’t need to be sorted since VLOOKUP is using exact match.
As always, if VLOOKUP can’t find a match, it will return #N/A.