Explanation
The AND function is designed to evaluate multiple logical expressions, and returns TRUE only when all expressions are TRUE.
In this case the we simply compare one range with another with a single logical expression:
B5:D12=F5:H12
The two ranges, B5:B12 and F5:H12 are the same dimensions, 5 rows x 3 columns, each containing 15 cells. The result of this operation is an array of 15 TRUE FALSE values of the same dimensions:
{TRUE,TRUE,TRUE; TRUE,TRUE,TRUE; TRUE,TRUE,TRUE; TRUE,TRUE,TRUE; TRUE,TRUE,TRUE; TRUE,TRUE,TRUE; TRUE,TRUE,TRUE; TRUE,TRUE,TRUE}
Each TRUE FALSE value is the result of comparing corresponding cells in the two arrays.
The AND function returns TRUE only if all values in the array are TRUE. In all other cases, AND will return FALSE.
Case-sensitive option
The formula above is not case-sensitive. To compare two ranges in a case-sensitive manner, you can use a formula like this:
{=AND(EXACT(range1,range2))}
Here, the EXACT function is used to make sure the test is case-sensitive. Like the formula above, this is an array formula and must be entered with control + shift + enter.
Explanation
This formula relies on the standard behavior of the COUNTIF function. The range is C5:C8, the criteria is provided as not equals OK:
=COUNTIF(C5:C8,"<>ok")
The COUNTIF then returns a count of any cells that do not contain “OK” which is compared to zero. If the count is zero, the formula returns TRUE. If the count is anything but zero, the formula returns FALSE.
Ignore empty cells
To ignore empty cells, you can use a more generic version of the formula:
=COUNTIF(range,value)=COUNTA(range)
This formula generates a count of all matching values and compares that count to a count of all non-empty cells.
Non-contiguous cells
If the cells are not in a contiguous range, you can use the AND function and a more manual approach. For example, to check that cells A1, A3, A5, and A9 contain “OK”, you can use a formula like this:
=AND(A1="ok",A3="ok",A5="ok",A9="ok")
Excel is not case-sensitive by default, so using “OK” or “ok” will return the same result.