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 toC7 - 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"
B225.03The value in B2.
$F$125The value in F1.
B2-$F$10.03The - operator subtracts.
ABS(B2-$F$1)0.03ABS: Absolute value.- number
B2-$F$10.03
- number
$F$20.05The value in F2.
ABS(B2-$F$1)<=$F$2TRUEThe <= operator tests at most.
IF(ABS(B2-$F$1)<=$F$2,"Pass","Fail")"Pass"IF: Returns one value if a test is true, another if false.- logical_test
ABS(B2-$F$1)<=$F$2TRUE - value_if_true
"Pass" - value_if_false
"Fail"not used
- logical_test
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.
| Formula | Result | When 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
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.