keepcalculator

06 Numbers and Powers

XLOOKUP Lookup Left? How to Return Values from the Left

Card No. 06·56178 · Updated · Standard formula, shown below

Yes. XLOOKUP can look up a value in one range and return a matching value from a range to its left; unlike VLOOKUP, it does not require the return column to be on the right. Select the lookup range and return range separately, and XLOOKUP matches their positions.

How XLOOKUP Looks Up Values

XLOOKUP searches a specified lookup array for a value and returns the item at the same relative position in a return array. The basic syntax is:

=XLOOKUP(lookup_value, lookup_array, return_array, [if_not_found], [match_mode], [search_mode])

For a left-side lookup, the lookup array can be a column farther right than the return array. For example, suppose A2:A5 contains employee names and C2:C5 contains employee IDs. To find a name from its ID, use:

=XLOOKUP(E2, C2:C5, A2:A5, "Not found")

If E2 contains an ID, Excel searches column C and returns the name in column A from the corresponding row. The order of the ranges in the formula—not their left-to-right position on the worksheet—determines the lookup and return roles.

Why It Can Return Values to the Left

Traditional VLOOKUP searches the first column of a table array and returns a value from a column to its right, identified by a column number. That structure makes a direct lookup to the left awkward: the desired return column cannot be placed before the search column within the table array.

XLOOKUP avoids that restriction because it takes the lookup array and return array as separate arguments. They can be in either order on the sheet, provided their corresponding entries line up. This also means you do not need to count columns or adjust a column index when the table changes.

  • Lookup array: the cells XLOOKUP searches.
  • Return array: the cells containing the answer to return.
  • Matching position: the position of the found item in the lookup array, used to select the corresponding item in the return array.

Step-by-Step Example

Imagine a table with product names in A2:A6 and product codes in D2:D6. Cell F2 contains a code, and you want the product name. Enter:

=XLOOKUP(F2, D2:D6, A2:A6, "Code not found")
  1. Use F2 as the value to find.
  2. Set D2:D6 as the lookup array because that column contains codes.
  3. Set A2:A6 as the return array because that column contains names.
  4. Provide “Code not found” as the result when no matching code exists.

For instance, if the code in F2 matches D4, the formula returns A4. XLOOKUP does not return the value from the same-numbered worksheet row by coincidence; it returns the item at the same position within the selected ranges.

Exact Matches, Missing Values, and Other Options

By default, XLOOKUP uses exact matching. That is usually what you want for IDs, names, product codes, and other distinct labels. If an exact match is absent, Excel normally returns an #N/A error. The optional if_not_found argument lets you supply a clearer message, such as “No match” or an empty string.

The fifth argument, match_mode, changes how XLOOKUP matches. Its options include exact match (the default), exact match or next smaller item, exact match or next larger item, and wildcard matching. Approximate matching is useful for ordered thresholds, but the lookup data must be arranged appropriately for the intended result. Wildcard matching can help with text patterns; use the relevant wildcard characters supported by Excel.

The sixth argument, search_mode, controls search direction and certain binary-search options. The usual default searches from the first item to the last. A reverse search can find the last matching entry, which is handy when a list contains repeated keys and the most recent row is at the bottom. Binary search modes require data sorted in the required order; using them on unsorted data can produce incorrect results.

Common Problems to Check

  • Range sizes do not match: The lookup and return arrays should have the same number of rows or columns. For example, C2:C100 paired with A2:A99 is misaligned and can cause an error.
  • Wrong orientation: A vertical lookup array should normally pair with a vertical return array; a horizontal lookup row should pair with a corresponding return row.
  • Numbers stored as text: A code that looks like 123 may be stored as text in one place and as a number in another. Check the underlying values and make their types consistent.
  • Extra spaces or hidden characters: Text values that look identical may differ because one contains leading, trailing, or nonprinting characters. Cleaning the source data can resolve unexpected #N/A results.
  • Duplicate lookup values: A normal search returns the first matching item in the chosen search direction. If duplicates exist, decide whether the first or last match is intended.
  • Incorrect approximate-match assumptions: Use exact matching for identifiers. For thresholds, verify both the match mode and the sort order rather than assuming the nearest value is automatically correct.

XLOOKUP Compared with VLOOKUP and INDEX/MATCH

For a straightforward lookup to the left, XLOOKUP is generally easier to read than a VLOOKUP workaround. VLOOKUP’s column index is tied to the table array, and its ordinary search direction is from the first column toward columns on the right. One workaround is to rearrange or duplicate columns, but that can make a workbook harder to maintain.

INDEX and MATCH can also return a value to the left. A typical formula uses MATCH to find the lookup value’s position, then INDEX to return the item at that position. This approach remains useful in older Excel versions that do not include XLOOKUP, and it can handle flexible layouts, but it takes more pieces to write. XLOOKUP combines the search and return logic in one function.

Availability depends on the spreadsheet application and version. If Excel reports that XLOOKUP is not recognized, the installed version may not support it. In that case, INDEX/MATCH is a common alternative; check compatibility before sharing a workbook with people using older software.

Frequently Asked Questions

Can XLOOKUP return a value from a column on the left?
Yes. Put the right-side column in lookup_array and the left-side column in return_array. Their entries must correspond in the same order.

What is the formula for an XLOOKUP to the left?
For example, =XLOOKUP(E2, C2:C100, A2:A100, "Not found") searches C2:C100 for E2 and returns the corresponding value from A2:A100.

Does XLOOKUP need the lookup column to be first?
No. The lookup array can be anywhere relative to the return array. You explicitly identify both ranges in the formula.

Can XLOOKUP return multiple columns?
Yes. In Excel versions that support dynamic arrays, the return array can include multiple adjacent columns. A matching row can then spill its corresponding values into neighboring cells, provided those cells are available.

Why does my left lookup return #N/A?
The lookup value may not exactly match anything in the lookup array. Check for text-versus-number differences, extra spaces, misspellings, and whether the formula points to the intended ranges. You can also use the optional not-found argument to display a clearer message.

Related

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

The whole Numbers and Powers drawer →