logo
search
Function Problems

How to Look Up a Value from Two Possible Columns in Excel

Chanuka GeekiyanageChanuka Geekiyanage Sep 27, 2026 869 views

Question details

The user needs a formula to look up a corresponding value from a mapping worksheet when the search key could be located in either of two possible columns.

How to Look Up a Value from Two Possible Columns in Excel
Product
Excel and WPS Spreadsheet
Device & OS
not provided
Scenario
Data mapping and lookup where the exact column containing the lookup value is uncertain.
Observed behavior
Standard lookup functions only search one specific column, returning an error if the value is located in the alternative column.
Before you start

Verify that your mapping worksheet contains clear, distinct columns for the lookup keys and return values, and ensure your spreadsheet software supports the XLOOKUP function.

Solution 1Recommended

Use a Combined IFERROR and XLOOKUP Formula

This approach attempts to find the value in the first column, and if it results in an error, automatically falls back to searching the second column.

By nesting an XLOOKUP function inside an IFERROR function, you can instruct the spreadsheet to check a primary column first. If the lookup value is not found there, IFERROR triggers the second XLOOKUP to check the secondary column.

1
Select the target cell

Click on the cell where you want the mapped region or corresponding value to appear.

2
Input the fallback formula

Type the formula: =IFERROR(XLOOKUP(F2,Map!A:A,Map!B:B), XLOOKUP(G2,Map!A:A,Map!B:B,"")). Adjust 'F2' and 'G2' to match your possible input cells, and 'Map!A:A' and 'Map!B:B' to match your actual mapping worksheet and column ranges.

3
Apply the formula

Press Enter to execute the formula. Then, click and drag the fill handle at the bottom right corner of the cell down to apply it to the rest of the column.

Use a Combined IFERROR and XLOOKUP Formula
Function Compatibility: XLOOKUP is available in modern spreadsheet applications like Microsoft 365 and recent versions of WPS Office. If you are using an older version, you can achieve the same result using VLOOKUP: =IFERROR(VLOOKUP(F2,Map!A:B,2,FALSE), VLOOKUP(G2,Map!A:B,2,FALSE)).

Effortlessly Manage Complex Lookups with WPS Spreadsheet

WPS Spreadsheet provides robust, built-in support for advanced functions like XLOOKUP and IFERROR, allowing you to seamlessly map and look up data across multiple columns without compatibility issues.

  1. 1. Open your dataset in WPS: Launch WPS Office and open your .xlsx file containing the data and mapping worksheets.
  2. 2. Insert the primary lookup: Select your output cell and start typing the IFERROR and XLOOKUP formula to target your first potential column.
  3. 3. Add the secondary lookup: Complete the formula by inserting the second XLOOKUP as the fallback condition within the IFERROR function.
  4. 4. Populate the column: Press Enter, then double-click the fill handle to automatically map the values for all remaining rows.
100% compatible with Microsoft Excel formulas and file formats (.xlsx, .xls).Built-in advanced functions including XLOOKUP for easier data analysis.Lightweight software with a familiar, easy-to-use tabbed interface.Free access to essential spreadsheet tools and everyday office utilities.
microsoft office alternative - wps office

Frequently Asked Questions

Can I look up a value across more than two columns?

Yes, you can nest multiple IFERROR functions to check three or more columns. For example: =IFERROR(XLOOKUP(F2,...), IFERROR(XLOOKUP(G2,...), XLOOKUP(H2,...))).

Why does my formula return a #REF! error?

A #REF! error typically occurs if the worksheet referenced in the formula (such as 'Map!') has been deleted or renamed, or if the column ranges are invalid. Ensure the sheet name in your formula exactly matches the actual tab name at the bottom of your workbook.

What does the "" at the end of the XLOOKUP formula do?

The empty double quotes "" serve as the 'if_not_found' argument for the second XLOOKUP. If the value is found in neither the first nor the second column, the formula will return a blank cell instead of an ugly #N/A error.