Function Problems

Compare Excel Columns and Return a Matching Value in Column B

Maira MehtabMaira Mehtab Dec 2, 2026 869 views

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.

Compare Excel Columns and Return a Matching Value 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.
Before you start

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.

Solution 1Recommended

Use XLOOKUP to Return the Corresponding Value

Use this formula in Excel versions that support XLOOKUP.

1
Enter the lookup formula

Select cell B5 and enter =XLOOKUP(M5,$O$1:$O$223,$P$1:$P$223,"").

2
Fill the formula down

Press Enter, then drag the fill handle from B5 down column B for the rows you need.

Use XLOOKUP to Return the Corresponding Value
Formula behavior: XLOOKUP returns the first exact match and displays a blank when no match is found. If your regional settings require semicolons, replace the commas with semicolons.
Compare columns in WPS Spreadsheet

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. 1. Open the workbook: Open WPS Spreadsheet and select Open to load your Excel workbook.
  2. 2. Enter the formula: Select B5 and enter =IFERROR(INDEX($P$1:$P$223,MATCH(M5,$O$1:$O$223,0)),"").
  3. 3. Fill down: Press Enter and drag the fill handle from B5 down to apply the formula to the remaining rows.
  4. 4. Save the workbook: Select Save or Save As to save the updated workbook in your preferred Excel-compatible format.
Return matching values automatically with spreadsheet formulasOpen and edit Microsoft Excel XLSX and XLS filesUse a familiar spreadsheet interfaceGet started with the free version of WPS Office
microsoft office alternative - wps office

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.