3 ms·
You may already know this, but if not and for others: my Excel files became a lot more manageable, maintainable, and readable when I switched from _LOOKUP() fun
by Cogito 4y ago
You may already know this, but if not and for others: my Excel files became a lot more manageable, maintainable, and readable when I switched from _LOOKUP() functions to the INDEX-MATCH pattern, and in particular using the pattern with Tables.
Basically
- Put the data to be looked up in a named Excel Table with a short, meaningful name. `data` is a good default name, but something with more meaning is better.
- Put the lookup 'results' in an Excel Table (naming optional but recommended). The output will be one column of the table, with one of the other columns used as input.
- Construct the output formula like `=INDEX(data[[value_column]], MATCH([@[input_column]], data[[lookup_column]], 0))`.
- (Optional) Put all formulas at the far right of the results table, so that you can copy new data into the left side easily without overwriting the formulas.
The MATCH finds the first row in `data` that has the lookup value from `input_column` (in the current table) in the `lookup_column` (in the data table). The INDEX grabs the value from `value_column` of the `data` table in that row.
Using Excel Tables helps by making the formulas more readable, and resistant to change. If new columns are added or removed the formulas continue to work (not true for how most _LOOKUP formulas are written), and the formula gets copied down to new rows as you add them.
You can switch to row lookups if needed (though you can't really use Excel Tables anymore)
if you need dynamic lookups you can specify both row and column as MATCHes in the INDEX formula (and INDEX against the whole `data` table instead of just one column). Something like `=INDEX(data, MATCH([@[input_column]], data[[lookup_column]], 0), MATCH([@[column_name]], data[#Headers], 0))`.
- rr888 4y agoI was going to reply with this too. Joel Spolsky explains it well https://youtu.be/0nbkaYsR94c?t=1824 https://youtu.be/0nbkaYsR94c?t=1824