Excel: Embed a Small Lookup Table In Formula

This page is an advertiser-supported excerpt of the book, Power Excel 2010-2013 from MrExcel - 567 Excel Mysteries Solved. If you like this topic, please consider buying the entire e-book.


Problem: I have a small 5-row lookup table hidden out in column AA:AB. The sales reps who use the spreadsheet might inadvertently delete a row in their data, deleting the lookup table. Can I put the lookup table somewhere that they won't destroy it?

Strategy: One solution is to move the lookup table to a new worksheet and hide the worksheet. However, if the lookup table is small, you can embed it right in the VLOOKUP formula. Follow these steps:

  1. Select the cell with the VLOOKUP formula.
  2. Press F2 to put the cell in edit mode
  3. Select the characters that represent the lookup table.

  1. Select the table array portion of the formula.
    1. Press F9. This calculates the selected portion of the formula. In this case, it puts {"œA",28;"B",35;"C",28;"D",14;"E",35} into the formula.

  2. Press F9. Excel inserts the array into the formula.
    1. Enter the formula. Copy it down to the other rows. You can now safely delete the lookup table.

    It helps to understand Excel's array syntax. The curly braces indicate that this is an array. Each comma means you should move to a new column. Each semicolon means that you should move to a new row.

    Gotcha: It is difficult to later edit the table. You can try to puzzle it out by staring at the commas and semi-colons in the formula bar. Or, you can copy the array and put it back in the worksheet. You have to follow these steps:

    1. Select the array from the formula, including the curly braces.
    2. Ctrl+C to copy the characters from the clipboard.
    3. Select a five-row by 2 column blank section of the spreadsheet.
    4. Type an equals sign. Press Ctrl+V. Press Ctrl+Shift+Enter. Excel will put the array back into the worksheet as an array formula. This looks OK, but you can not edit individual cells in the range.

  3. The table is back, but it is not editable, yet.
    1. With the entire range selected, do a Copy and then Paste Values. You can now edit individual cells in the table.

For more resources for Microsoft Excel