Yes, you can make a self-contained VLOOKUP in Excel by embedding the lookup table directly inside the formula using array constants, so you don’t need a separate range on the sheet. This works best for small, fixed lookup tables that never change, and you enter it the same way as a normal VLOOKUP — just with the table array written out in curly braces.
Formula
The self-contained VLOOKUP uses the standard syntax:
VLOOKUP(lookup_value, table_array, col_index_num, [range_lookup])
But instead of referencing a cell range like A2:B5, you write the table directly as an array constant: {1,"Low";2,"Medium";3,"High"}. The semicolon separates rows, and the comma separates columns (in most regional settings). The first column is the lookup column, and the column index number tells Excel which column to return.
Worked Example
Suppose you want to assign a rating based on a score, with no helper table on the sheet. In cell A1 you type a score, say 2. The formula:
=VLOOKUP(A1,{1,"Low";2,"Medium";3,"High"},2,FALSE)
Excel evaluates the array constant as a 3-row, 2-column table. It looks for the value 2 in the first column, finds it in the second row, and returns the corresponding second-column value “Medium�. If you change A1 to 3, it returns “High�. The array constant is part of the formula itself, so there is no dependency on a worksheet range.
Why Use a Self-Contained Lookup?
The main advantage is portability. If you copy the formula to another workbook, it carries its own table — no need to also copy a hidden sheet or named range. This is handy for small, fixed mappings like status codes, grade boundaries, or short conversion factors. It also prevents users from accidentally editing or deleting the lookup table, because there is no table to edit.
However, the trade-off is readability and maintenance. A long array constant inside a formula is hard to read and even harder to update. If you need to add a row, you must edit the formula itself, and any mistake in the syntax (like a missing semicolon) can break the whole formula. For anything more than a handful of rows, a normal range is usually better.
How to Enter a Self-Contained VLOOKUP
Entering the formula is straightforward, but there are a few pitfalls:
- Type the formula normally, with the array constant in curly braces. In Excel 365 and Excel 2021, you just press Enter. In older versions, you may need to confirm with Ctrl+Shift+Enter if the formula returns multiple values, but for a single VLOOKUP result, regular Enter usually works.
- Use semicolons to separate rows and commas to separate columns. If your regional settings use semicolons as argument separators, you may need to use backslashes or different separators — check Excel’s list separator setting.
- Keep the array constant small. Excel has a limit of 255 characters for a formula’s array constant, and longer formulas become difficult to debug.
- For approximate matches (range_lookup TRUE), the first column must be sorted in ascending order, just like a normal VLOOKUP.
Common Problems and How to Fix Them
The most frequent issue is a #N/A error, which means the lookup value isn’t found in the first column. With an array constant, double-check that the value exists and that the data types match (e.g., text vs. number). Another common problem is the #VALUE! error, which usually means the array constant syntax is wrong — a missing semicolon or comma, or an extra brace. Also, if you use a comma as the decimal separator in your region, the array constant may interpret commas as decimal points, causing errors. In that case, use backslashes instead of commas to separate columns.
Another issue is that the formula returns the wrong column. Remember that the column index is counted from the first column of your array constant, not from the sheet. If your array has 3 columns and you ask for column 4, you’ll get a #REF! error.
When to Use a Regular Range Instead
A self-contained VLOOKUP is best for tiny, static tables — maybe up to 5 rows. If your table is larger, changes frequently, or is used by multiple formulas, a regular range is far more practical. You can name the range (e.g., StatusCodes) to make formulas readable, and you can add rows without editing every formula. Also, if you need to use the lookup table in data validation or conditional formatting, a range is required — array constants cannot be referenced by those features.
Alternatives to Self-Contained VLOOKUP
If you want the portability of an embedded table but need more flexibility, consider these alternatives:
- XLOOKUP (Excel 365/2021): allows a similar array constant as the lookup array, and you can specify the return array separately. It’s more flexible and doesn’t require the lookup column to be the first column.
- CHOOSE with MATCH:
=CHOOSE(MATCH(A1,{1,2,3},0),"Low","Medium","High")— this works for simple lists and is sometimes easier to read. - IFS or SWITCH: for a small number of exact matches, a nested IF or IFS function may be clearer.
- Named constants: you can define a name that refers to an array constant (e.g., name
RatingTablerefers to={1,"Low";2,"Medium";3,"High"}) and then use that name in your VLOOKUP. This keeps the formula short while still embedding the table.
Frequently Asked Questions
Can I use a self-contained VLOOKUP with approximate match?
Yes, you can set the range_lookup argument to TRUE or omit it, but the first column of the array constant must be sorted in ascending order. For example, =VLOOKUP(2.5,{1,"Low";2,"Medium";3,"High"},2,TRUE) returns “Medium� because 2.5 is between 2 and 3. Be careful with exact vs. approximate: if you use FALSE, it requires an exact match, which is often safer.
Why does my array constant give a #VALUE! error?
This usually means the syntax is wrong. Check that rows are separated by semicolons and columns by commas (or backslashes in some regional settings). Also ensure you have the same number of columns in each row — a missing value will cause an error.
Is there a size limit for the array constant in a formula?
Yes, Excel limits the length of a formula to 8,192 characters, and array constants themselves are limited to 255 characters. In practice, keep your self-contained lookup to a few rows to avoid hitting these limits and to keep the formula readable.
Can I use cell references inside the array constant?
No, array constants can only contain numbers, text, logical values, or error values — not cell references or formulas. If you need to mix references with constants, you must use a range or a named range instead.
Does this work in Google Sheets?
Google Sheets supports array constants in a similar way, but the syntax is slightly different: rows are separated by semicolons and columns by commas, just like Excel. However, Google Sheets may require you to wrap the formula in ARRAYFORMULA if you’re using it in a way that returns multiple values. For a single VLOOKUP, it generally works the same.
How do I edit a self-contained VLOOKUP later?
Simply click on the cell and edit the formula in the formula bar. Be careful to maintain the correct syntax. If you need to change the table, you have to edit every formula that contains it — another reason to use a range for tables that change often.
Related
Formula used
in t | Finish time | min | 50 | 0 in d | Distance | km | 10 | 0 | 100000 out pace | Average pace | min/km | t / d | 2 out speed | Average speed | km/h | d / (t / 60) | 2
Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.
More cards in this drawer
- Philips DST7060/20 7000 Series Iron: Specs & Fit
- Coal Fueled Jet Aircraft: Could It Work?675 L
- Remote Desktop on Raspberry Pi: How to Enable It
- Word Select Last Line in Paragraph?
- Google Assistant IFTTT Recipes: 7 Useful Automations
- OLED TVs in Dark Rooms: Why They Look Better and When They Don’t