When the value in column B is within +/- .005 of 0.250 (from column C), the formula returns “OK”. If not, the formula returns “Fail”.

Core logic

To check if a value is within a given tolerance, we can use a simple logical test like this: Inside the ABS function, the actual value is subtracted from the expected 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: negative values become positive and positive values are unchanged. The result from ABS is compared to the allowed tolerance with the logical operator less than or equal (<=).  The expression returns TRUE when a value is less than or equal to the allowed tolerance, and FALSE if not.

IF function

To complete the solution, we need to place the generic logical expression  above into the IF function and providing values for a TRUE and FALSE result. The first step is to revise the generic expression above to use worksheet references: Then, we drop the expression into the IF function as the logical_test argument: When the logical test returns TRUE, IF returns “OK”. When the logical test returns FALSE, IF returns “Fail”. These messages can be customized as needed.

List all values within tolerance

The basic concept explained above can be extended to list values within tolerance or out of tolerance with the FILTER function.

Dave Bruns

Hi - I’m Dave Bruns, and I run Exceljet with my wife, Lisa. Our goal is to help you work faster in Excel. We create short videos, and clear examples of formulas, functions, pivot tables, conditional formatting, and charts.