Function Problems

Compare Values Across Sheets and Return Matching Data in WPS Spreadsheets

John WilsonJohn Wilson Dec 2, 2026 868 views

Question details

Compare two values on one sheet with a lookup column on another sheet and return the match and related data.

Compare Values Across Sheets and Return Matching Data in WPS Spreadsheets
Product
WPS Spreadsheets
Device & OS
not provided
Scenario
Sheet1 columns B and C contain values to check against column A on Sheet2. The user wants a match indicator, the matching value, and related fields on Sheet1.
Observed behavior
Column E should show TRUE or FALSE, column F should show the matching value from Sheet2, and additional columns should display data from the matched row.
Before you start

Confirm that the sheets are named Sheet1 and Sheet2 and that the lookup values are in Sheet2 column A. Identify which Sheet2 columns contain the related fields you want to return.

Solution 1Recommended

Use COUNTIF and INDEX MATCH to return cross-sheet matches

Use these formulas to check both values, show the matching value, and retrieve fields from the same row on Sheet2.

The formulas check B2 first, then C2. If both match, B2 takes priority; if Sheet2 contains duplicate lookup values, INDEX MATCH returns the first matching row.

1
Check for a match

In Sheet1 cell E2, enter =OR(AND(B2<>"",COUNTIF(Sheet2!$A:$A,B2)>0),AND(C2<>"",COUNTIF(Sheet2!$A:$A,C2)>0)). The result is TRUE if either nonblank value appears in Sheet2 column A.

2
Return the matching value

In Sheet1 cell F2, enter =IF(E2,IF(AND(B2<>"",COUNTIF(Sheet2!$A:$A,B2)>0),B2,C2),""). This returns the matched value or leaves the cell blank if there is no match.

3
Retrieve a related field

In Sheet1 cell G2, enter =IF($E2,INDEX(Sheet2!B:B,MATCH($F2,Sheet2!$A:$A,0)),""). This returns the value from Sheet2 column B on the matching row.

4
Fill the formulas

Select E2:G2 and drag the fill handle down for the remaining records. To return another field, copy G2 to H2 so the return range changes from Sheet2 column B to column C, then fill it down.

Use COUNTIF and INDEX MATCH to return cross-sheet matches
Use your actual sheet names: If a sheet name contains spaces, enclose it in single quotes in the formula, such as 'Sheet 2'!$A:$A.
Compare spreadsheet records

Match records across sheets with WPS Spreadsheets

Use COUNTIF and INDEX MATCH in WPS Spreadsheets to check two values against a lookup sheet and return related fields from the matching row.

  1. 1. Open your workbook: Open the workbook in WPS Spreadsheets and select the Sheet1 tab.
  2. 2. Add the match test: Select E2 and enter =OR(AND(B2<>"",COUNTIF(Sheet2!$A:$A,B2)>0),AND(C2<>"",COUNTIF(Sheet2!$A:$A,C2)>0)).
  3. 3. Return the matched value: Select F2 and enter =IF(E2,IF(AND(B2<>"",COUNTIF(Sheet2!$A:$A,B2)>0),B2,C2),"").
  4. 4. Return related data and fill down: Select G2 and enter =IF($E2,INDEX(Sheet2!B:B,MATCH($F2,Sheet2!$A:$A,0)),""). Select E2:G2 and drag the fill handle down.
Check two input columns against a lookup columnReturn related fields from the first matching recordOpen and edit Microsoft Excel XLSX and XLS filesFill formulas down for multiple records
QA img-9

Frequently Asked Questions

What happens if both B2 and C2 match values on Sheet2?

The formula in F2 returns B2 first. The related-field formula then retrieves data from the row matching B2.

How do I return a different field from Sheet2?

In the INDEX formula, replace Sheet2!B:B with the column containing the field you need, such as Sheet2!C:C. Keep MATCH pointed at Sheet2!$A:$A.

What if Sheet2 contains duplicate lookup values?

MATCH returns the position of the first matching value in Sheet2 column A, so the related field comes from that first matching row.

Why does a value that looks identical not match?

Check for extra spaces or a number stored as text in Sheet1 columns B and C or Sheet2 column A. Correct the values or standardize their format, then recalculate the formulas.