Formula Errors

Fix an Excel IF Formula That Returns NO for Equal-Looking Values

Aamir Naveed AkramAamir Naveed Akram Dec 2, 2026 868 views

Question details

Compare two calculated values in an Excel IF formula when they look equal but the formula returns NO.

Fix an Excel IF Formula That Returns NO for Equal-Looking Values
Product
Microsoft Excel
Device & OS
not provided
Scenario
A formula compares the calculated values in cells R20 and E20 and should return YES when they are equal within the required precision.
Observed behavior
The values display as equal, but a direct comparison returns FALSE because their stored values may differ slightly.
Before you start

Check that R20 and E20 contain numeric values and identify the precision your calculation requires. Increasing the displayed decimal places can help reveal a difference, but cell formatting alone does not change the stored values.

Solution 1Recommended

Compare the Rounded Difference in Excel

Use this approach when a difference that rounds to zero at a chosen precision should count as equal.

1
Select the formula cell

Click the cell containing the IF formula that compares R20 and E20.

2
Round the difference

In the formula bar, replace the direct comparison with =IF(ROUND(R20-E20,5)=0,"YES","NO") and press Enter.

3
Set the precision

Change the 5 in ROUND to the number of decimal places appropriate for your calculation, then press Enter.

Compare the Rounded Difference in Excel
Choose precision carefully: Rounding the difference is not always the same as rounding each value separately. Use the comparison rule that matches your calculation requirements.
Compare values in WPS Spreadsheet

Compare Equal-Looking Values in WPS Spreadsheet

Open your workbook in WPS Spreadsheet and use ROUND or ABS in an IF formula to compare values at the precision your calculation requires.

  1. 1. Open the workbook: Open WPS Spreadsheet, select Open, and choose your Excel workbook.
  2. 2. Select the result cell: Click the cell where you want the comparison result.
  3. 3. Enter the formula: In the formula bar, enter =IF(ROUND(R20-E20,5)=0,"YES","NO") and press Enter.
  4. 4. Adjust and save: Change the cell references or decimal precision if needed, then select Save to save the workbook.
Compare calculated values using rounding or a toleranceOpen and save Microsoft Excel XLSX filesEdit formulas in a familiar spreadsheet interface
QA img-9

Frequently Asked Questions

Why does Excel return NO when two values look the same?

Excel may store calculated decimals with a tiny difference even when cell formatting displays the same rounded amount. A direct comparison such as R20=E20 tests the stored values.

Will changing the displayed decimal places fix the comparison?

No. Use the decimal-place controls on the Home tab to inspect the display, but use ROUND or a tolerance in the formula to change how the values are compared.

How do I compare values to the nearest cent?

If each amount should be rounded to cents before comparison, use =IF(ROUND(R20,2)=ROUND(E20,2),"YES","NO"). This can give a different result from rounding their difference.

How do I include a difference exactly equal to the tolerance?

Use <= in the tolerance comparison, for example =IF(ABS(R20-E20)<=0.00001,"YES","NO").