Fix an Excel IF Formula That Returns NO for Equal-Looking Values
Question details
Compare two calculated values in an Excel IF formula when they look equal but the formula returns NO.

- 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.
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.
Compare the Rounded Difference in Excel
Use this approach when a difference that rounds to zero at a chosen precision should count as equal.
Click the cell containing the IF formula that compares R20 and E20.
In the formula bar, replace the direct comparison with =IF(ROUND(R20-E20,5)=0,"YES","NO") and press Enter.
Change the 5 in ROUND to the number of decimal places appropriate for your calculation, then press Enter.

Compare Excel Values Using a Tolerance
Use a tolerance when differences smaller than a specific amount should count as equal.
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. Open the workbook: Open WPS Spreadsheet, select Open, and choose your Excel workbook.
- 2. Select the result cell: Click the cell where you want the comparison result.
- 3. Enter the formula: In the formula bar, enter =IF(ROUND(R20-E20,5)=0,"YES","NO") and press Enter.
- 4. Adjust and save: Change the cell references or decimal precision if needed, then select Save to save the workbook.

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").




