Explanation
This formula uses two named ranges, "range1" (B5:B12) and "range2" (D5:D10).
The core of this formula is the COUNTIF function, which returns a count of each value in both range inside the AND function:
COUNTIF(range1,B5) // count in range1
COUNTIF(range2,B5) // count in range2
COUNTIF will either return zero (evaluated as FALSE) or a positive number (evaluated as TRUE) for each value in both ranges.
If both counts are positive (i.e. non-zero), the AND function will return TRUE and trigger the conditional format.
Related formulas
Highlight duplicate values
Highlight duplicate rows
Range contains duplicates
Related functions
COUNTIF Function
The Excel COUNTIF function returns the count of cells in a range that meet a single condition. The generic syntax is COUNTIF(range, criteria), where "range" contains the cells to count, and "criteria" is a condition that must be true for a cell to be counted. COUNTIF can be used to count cells...
AND Function
The Excel AND function is a logical function used to test multiple conditions at the same time. AND returns TRUE only if all the conditions are met. If any conditions are not met, the AND function returns FALSE. The AND function is commonly used with other...