Spreadsheet Practice

How to check if a value is within a tolerance in Excel

Formula (Excel and Google Sheets)

=IF(ABS(B2-$F$1)<=$F$2,"Pass","Fail")

Compare the distance from the target with the tolerance: =IF(ABS(B2-$F$1)<=$F$2,"Pass","Fail").

Result on the example
one result per row in C2, filled down to C7
Works in
Every current version
Google Sheets
Same formula

See it work

The formula is already in C2, filled down to C7. Change any input and the result updates, or edit the formula to experiment.

How it works

ABS(B2-$F$1) is the distance from the target whichever side the measurement falls on. If that distance is at most the tolerance, the part passes. B-02 is 0.06 under the target and fails.

=IF(ABS(B2-$F$1)<=$F$2,"Pass","Fail")

Result"Pass"

  1. B225.03

    The value in B2.

  2. $F$125

    The value in F1.

  3. B2-$F$10.03

    The - operator subtracts.

  4. ABS(B2-$F$1)0.03

    ABS: Absolute value.

    • numberB2-$F$10.03
  5. $F$20.05

    The value in F2.

  6. ABS(B2-$F$1)<=$F$2TRUE

    The <= operator tests at most.

  7. IF(ABS(B2-$F$1)<=$F$2,"Pass","Fail")"Pass"

    IF: Returns one value if a test is true, another if false.

    • logical_testABS(B2-$F$1)<=$F$2TRUE
    • value_if_true"Pass"
    • value_if_false"Fail"not used

In Google Sheets

The same formula works in Google Sheets: =IF(ABS(B2-$F$1)<=$F$2,"Pass","Fail"). We ran it in Google Sheets mode on the same data and it returns the same results.

Other ways to do it

Each one was run on the same example sheet.

FormulaResultWhen to use it
=IF(AND(B2>=$F$1-$F$2,B2<=$F$1+$F$2),"Pass","Fail")Pass, Fail, Pass…The same window written as a lower and an upper limit.
=IF(ROUND(ABS(B2-$F$1),4)<=$F$2,"Pass","Fail")Pass, Fail, Pass…Rounds the deviation, so a value exactly on the limit isn't failed by a floating-point leftover.

Common mistakes

  • Values exactly on the limit can fail because decimals aren't stored exactly: 25.05-25 is 0.0500000000000007. Round the difference, as in the second alternative.
  • A percentage tolerance needs the target in it: ABS(B2-$F$1)<=$F$1*2%.

Try it yourself

Same data, empty answer cell. Your formula is graded instantly, then re-checked on changed data, so a typed-in number won't pass.

Check if a value is within a tolerance

In C2, show "Pass" when the measurement is within the tolerance in F2 of the target in F1, on either side, otherwise "Fail". Fill down to C7.

Questions

How do I show how far off each part is?

=B2-$F$1 gives the signed deviation.

How do I count the passes?

=COUNTIF(C2:C7,"Pass").

Checked by running on 2026-10-30: every formula and result on this page was calculated by the Spreadsheet Practice formula engine, in both Excel and Google Sheets modes.