COUNTIF checks if the value in B5 occurs in the named range "allowed". If the value is found, COUNTIF will return a positive number, if not, COUNTIF will return zero. This works perfectly as the logical test for IF.
With fixed values
The example above shows allowed values in a range of cells, but allowed values can also be hard-coded into the formulas as an array constant like this:
The IF function can perform a logical test and return one value for a TRUE result, and another for a FALSE result. For example, to "pass" scores above 70: =IF(A1>70,"Pass","Fail"). More than one condition can be tested by nesting IF functions....
COUNTIF is a function to count cells that meet a single criterion. COUNTIF can be used to count cells with dates, numbers, and text that meet specific criteria. The COUNTIF function supports logical operators (>,...
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.