How to Compare Excel Columns and Return Zero for Matches
Question details
The user wants a formula to compare values in column A and column C, which outputs 0 if the values are identical, and otherwise returns the value from column C.

- Product
- Spreadsheet
- Device & OS
- not provided
- Scenario
- Data comparison and reconciliation across multiple columns or sheets.
- Observed behavior
- The user needs a logical function (like IF) to automatically evaluate matching cell values and dynamically output either a zero or a referenced cell value.
Ensure both columns being compared contain the exact same data types (e.g., both text or both numbers) and have no hidden spaces, as formatting differences will cause the formula to see them as non-matching.
Use the IF Function for Cell Comparison
The most straightforward way to compare two cells and return a conditional value based on the result is by writing a simple IF function.
The IF function in spreadsheets allows you to make logical comparisons between a value and what you expect. In this scenario, we check if A2 equals C2. If it is true, the result is 0. If it is false, the result is whatever is currently inside C2.
Click on cell E2 where you want the result of the comparison to be displayed.
Type =IF(A2=C2,0,C2) into the formula bar and press the Enter key.
Click on cell E2 again, grab the small square (fill handle) in the bottom-right corner, and drag it one cell to the right into F2. If you are referencing different columns for F2's specific check, adjust the cell references inside the formula manually.
Double-click the fill handle on cell E2 to automatically copy the formula down the entire column for the rest of your dataset.

Compare Spreadsheet Data Quickly in WPS Office
WPS Spreadsheet is a powerful, reliable tool for data analysis. It supports all standard Excel functions like IF, VLOOKUP, and conditional formatting, allowing you to compare complex datasets with ease.
- 1. Open Your File in WPS: Launch WPS Office and open your .xlsx spreadsheet document containing the data to be compared.
- 2. Input the IF Formula: Click on cell E2, type =IF(A2=C2,0,C2), and hit Enter to process the first comparison.
- 3. Fill the Formula Across and Down: Use the smart fill handle in WPS Spreadsheet to drag the formula to the right into F2, and then drag it downwards to evaluate all rows in your dataset instantly.

Frequently Asked Questions
Why does my formula return the C2 value even when cells A2 and C2 look identical?
This generally happens if one of the cells contains hidden leading or trailing spaces, or if one is formatted as text while the other is a number. Use the TRIM() function, such as =IF(TRIM(A2)=TRIM(C2),0,C2), to remove extra spaces.
How can I compare columns without making the non-matching cells return the C2 value?
If you want non-matching cells to remain blank or display custom text like 'Mismatch', simply modify the third argument of your IF statement. For example, use =IF(A2=C2,0,"") to leave it blank, or =IF(A2=C2,0,"Mismatch").
Can I use this formula to compare data on different worksheets?
Yes, you can compare values across multiple sheets by including the sheet name followed by an exclamation mark. For example: =IF(Sheet1!A2=Sheet2!C2, 0, Sheet2!C2).
Does case sensitivity matter when comparing text in A2 and C2?
The standard IF function with the equals sign (=) is not case-sensitive, meaning 'Apple' and 'apple' will be treated as a match. To make the comparison strictly case-sensitive, use the EXACT function: =IF(EXACT(A2,C2),0,C2).




