Function Problems

Compare Cells in Excel and Return Blank or TRUE/FALSE

Steven ParkerSteven Parker Nov 18, 2026 869 views

Question details

Create a formula that returns a blank when two cells are empty and otherwise compares their values.

Compare Cells in Excel and Return Blank or TRUE/FALSE
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.
Before you start

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.

Solution 1Recommended

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.

1
Select the result cell

In Excel, select cell D3.

2
Enter the formula

Type =IF(AND(B3="",C3=""),"",B3=C3) in D3 and press Enter.

3
Apply it to other rows

If needed, drag the fill handle from D3 down the column to compare B and C in subsequent rows.

Use IF and AND to compare the cells
A blank-looking result: The formula returns an empty text string when both inputs are empty; the result cell still contains a formula.
Compare cells in WPS Spreadsheets

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. 1. Open your spreadsheet: Open WPS Spreadsheets and select Open to load your workbook.
  2. 2. Select the output cell: Click D3, or choose another cell where you want the comparison result.
  3. 3. Enter the comparison formula: Enter =IF(AND(B3="",C3=""),"",B3=C3) and press Enter.
  4. 4. Fill additional rows: Drag the fill handle down from D3 to apply the formula to other rows.
Compare cells and suppress results for empty input pairsOpen and edit Microsoft Excel XLSX and XLS filesUse familiar spreadsheet formulas and fill controls
microsoft office alternative - wps office

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.