Exceljet

Quick, clean, and to the point

Value is within tolerance

Excel formula: Value is within tolerance
Generic formula 
=IF(ABS(actual-expected)<=tolerance,"OK","Fail")
Explanation 

To test if a value is within expected tolerance or not, and report "pass" or "fail", you can use a formula based on the IF and ABS functions. In the example shown, the formula in E5 is:

=IF(ABS(B5-C5)<=D5,"OK","Fail")

How this formula works

Inside the IF function, the expected value is subtracted from the measured or actual value. The result may be positive or negative, depending on the actual value, so the ABS function is used to convert the result to a positive number in all cases. This number is then compared to the allowed tolerance as a logical test inside IF. If the difference is less than or equal to the allowed tolerance, IF returns "OK". If not, IF returns "Fail". These messages can be customized as needed.

Author 
Dave Bruns

Excel Formula Training

Formulas are the key to getting things done in Excel. In this accelerated training, you'll learn how to use formulas to manipulate text, work with dates and times, lookup values with VLOOKUP and INDEX & MATCH, count and sum with criteria, dynamically rank values, and create dynamic ranges. You'll also learn how to troubleshoot, trace errors, and fix problems. Instant access. See details here.