How to Ignore Blank Cells When Comparing Two Excel Columns
Question details
Create an Excel formula that compares two columns for differences but ignores rows where one or both cells are blank to avoid false mismatch reports.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Comparing two data lists to identify differences while skipping incomplete records or empty cells.
- Observed behavior
- Standard comparison formulas flag a mismatch when one cell contains data and the adjacent comparison cell is blank, leading to false positives in the results.
Identify the exact columns you want to compare and determine whether cells containing invisible space characters should also be treated as blank.
Use the IF and AND Functions to Exclude Blank Cells
This is the most direct method to ensure both comparison cells contain data before evaluating them for a mismatch.
By combining the IF and AND functions, you can instruct Excel to first verify that neither cell is empty. If both cells are populated and do not match, the formula will flag them. Otherwise, it will leave the result cell blank.
Click on an empty cell in a new column (e.g., E2) where you want the comparison result to be displayed.
Type the formula: =IF(AND(C2<>"",D2<>"",C2<>D2),"No match",""). This assumes you are comparing data in cells C2 and D2.
Press Enter to execute the formula. Then, click and drag the fill handle at the bottom-right corner of the cell to apply this formula down your entire list.

Use TRIM to Handle Cells Containing Only Spaces
If your data was imported or manually entered, some cells may look blank but actually contain hidden spaces. This solution treats those cells as truly blank.
Compare Data Easily with WPS Spreadsheet
WPS Spreadsheet fully supports advanced logical formulas like IF, AND, and TRIM, making data comparison completely seamless and accurate.
- 1. Open your workbook: Launch WPS Spreadsheet and open your existing file containing the columns you need to compare.
- 2. Apply the comparison formula: Click your target cell and type the =IF(AND(C2<>"",D2<>"",C2<>D2),"No match","") formula.
- 3. Fill down automatically: Double-click the bottom-right corner of the cell to instantly apply the comparison logic across all your rows.

Frequently Asked Questions
How do I highlight the mismatched cells instead of using a formula column?
You can use Conditional Formatting. Select your data columns, navigate to Home > Conditional Formatting > New Rule, choose to use a formula, and enter =AND($C2<>"", $D2<>"", $C2<>$D2). Choose a fill color and click OK. This will highlight differences only when both cells have data.
Can I output the word 'Match' when they are equal instead of leaving it blank?
Yes, you can modify the IF formula to account for matches. Use this structure: =IF(OR(C2="",D2=""),"", IF(C2=D2,"Match","No match")). This checks if either is blank first; if not, it evaluates if they match or mismatch.
Why is my formula returning an error?
Errors usually occur due to incorrect cell references or syntax typos. Ensure that your cell references (like C2 and D2) correctly point to the columns you are comparing, and double-check that you haven't missed any commas or quotation marks in the formula.




