Compare Cells in Excel and Return Blank or TRUE/FALSE
Question details
Create a formula that returns a blank when two cells are empty and otherwise compares their values.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- Compare the values in B3 and C3 and display the result in D3.
- Observed behavior
- D3 should appear blank when both input cells are empty; otherwise, it should display the result of the equality comparison.
Identify the two cells to compare and an empty cell for the result. The example uses B3 and C3 as inputs and D3 for the formula.
Use IF and AND to compare the cells
Use this formula to leave the result visually blank when both inputs are empty and otherwise return the equality comparison.
In Excel, select cell D3.
Type =IF(AND(B3="",C3=""),"",B3=C3) in D3 and press Enter.
If needed, drag the fill handle from D3 down the column to compare B and C in subsequent rows.

Compare cell values with a formula in WPS Spreadsheets
Use the same IF and AND formula in WPS Spreadsheets to show a blank for two empty inputs and compare their values otherwise.
- 1. Open your spreadsheet: Open WPS Spreadsheets and select Open to load your workbook.
- 2. Select the output cell: Click D3, or choose another cell where you want the comparison result.
- 3. Enter the comparison formula: Enter =IF(AND(B3="",C3=""),"",B3=C3) and press Enter.
- 4. Fill additional rows: Drag the fill handle down from D3 to apply the formula to other rows.

Frequently Asked Questions
What does the formula return when both cells are empty?
The IF function returns an empty text string, so D3 appears blank even though it contains a formula.
What happens when the cells contain values?
The formula evaluates B3=C3 and returns TRUE if Excel considers the values equal or FALSE if it does not.
Can I compare cells in other columns?
Yes. Replace B3 and C3 in =IF(AND(B3="",C3=""),"",B3=C3) with the cell references you want to compare.
Why does a cell containing spaces not count as empty?
A space is a character, so a cell containing spaces does not satisfy the test B3="". Remove the spaces from the input cell if it should be empty.




