For the sake of this question, let’s say I have an Excel data source spreadsheet with various liquor types.
(Cell A) | (Cell B)
Bacardi | Rum
Smirnoff | Vodka
Another Vodka | Vodka
Yet Another Vodka | Vodka
Malibu | Rum
Meyers | Rum
etc.
On a separate sheet within the document I want to list it as follows:
RUM
Bacardi
Malibu
Meyers
----------
VODKA
Smirnoff
Another Vodka
Yet Another Vodka
… where RUM is one category and VODKA is another.
How would I convert my data source (first example) into the second example?
It’s not the most elegant, and by far not the most efficient way, but here’s how to do it using 2 dictionaries in case you’re in a rush!
How it works: Using a dictionary to separate main categories and sub items (by concatenating them as the item for that key) is very convenient.
You could work out ways to slap that back onto Excel but it requires resizing and It’s a hassle. Since the dictionary comes with the ability to transpose all keys or items, I opted to dump the key-item pairs (technically in order now) into another dictionary, but as items instead of keys, so I can keep dupes. It also let’s you do final data massaging like uCase the categories and add seperators, etc. Then I just transpose the result.
Unconventional, maybe, but fun and works!