Compare Excel Columns and Return a Matching Value in Column B
Question details
Compare a calculated value in column M with a lookup range in column O and return the corresponding value from column P in column B.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- Each value in column M needs to be looked up in column O so that the associated value from column P appears in the same row of column B.
- Observed behavior
- Column B should automatically display the matching value from column P, or remain blank if no match is found.
Check that the lookup values are in O1:O223 and their corresponding results are in P1:P223. Make sure the calculation in column M does not depend on the result in column B, which would create a circular reference.
Use XLOOKUP to Return the Corresponding Value
Use this formula in Excel versions that support XLOOKUP.
Select cell B5 and enter =XLOOKUP(M5,$O$1:$O$223,$P$1:$P$223,"").
Press Enter, then drag the fill handle from B5 down column B for the rows you need.

Use INDEX and MATCH in Older Excel Versions
Use this alternative if XLOOKUP is not available in your version of Excel.
Return Matching Values with WPS Spreadsheet
Use INDEX and MATCH in WPS Spreadsheet to compare column M with column O and return the corresponding value from column P.
- 1. Open the workbook: Open WPS Spreadsheet and select Open to load your Excel workbook.
- 2. Enter the formula: Select B5 and enter =IFERROR(INDEX($P$1:$P$223,MATCH(M5,$O$1:$O$223,0)),"").
- 3. Fill down: Press Enter and drag the fill handle from B5 down to apply the formula to the remaining rows.
- 4. Save the workbook: Select Save or Save As to save the updated workbook in your preferred Excel-compatible format.

Frequently Asked Questions
What happens if column O contains duplicate matches?
Both formulas return the value from column P associated with the first matching entry in O1:O223.
Why does the formula use dollar signs in the lookup ranges?
The dollar signs lock O1:O223 and P1:P223, so those ranges stay fixed when you drag the formula down column B.
Why is the result blank when a match appears to exist?
Check whether the value in column M and the value in column O have different data types or extra spaces. For the INDEX and MATCH formula, IFERROR can also hide other formula errors.
Can I use the formula if my lookup list extends beyond row 223?
Yes. Edit both ranges in the formula to cover the full list, such as $O$1:$O$500 and $P$1:$P$500. Keep the ranges aligned and the same size.




