Explanation

This formula uses 4 named ranges, defined as follows:

width=K6
height=K7
widths=B6:B11
heights=C5:H5

Conditional formatting is evaluated relative to every cell it is applied to, starting with the active cell in the selection, which is cell B5 in this case. To highlight the matching row, we use this logical expression:

$B5=LOOKUP(width,widths)

The reference to B5 is mixed , with the column locked and row unlocked, so that only values in column B (widths) are compared to the value in K6 (width). In the example shown, this logical expression will return TRUE for every cell in a row where the width is 200, based on an approximate match of the value in K6 (width, 275) against all values in K6:B11 (widths). This is done with the LOOKUP function:

LOOKUP(width,widths)

Like the MATCH function, LOOKUP will run through sorted values until a greater value is found, then “step back” to the previous value, which is 200 in this case.

To highlight the matching column, we use this logical expression:

B$5=LOOKUP(height,heights)

The reference to B5 is mixed, with the column relative and row absolute , so that only values in row 5 (heights) are compared to the value in K7 (height). In the example shown, this logical expression will return TRUE for every cell in a row where the height is 300, based on an approximate match of the value in K7 (height, 325) against all values in C5:H5 (heights). This is done with the LOOKUP function:

LOOKUP(height,heights)

As above, LOOKUP will run through sorted values until a greater value is found, then “step back” to the previous value, which is 300 in this case.

Highlight intersection only

To highlight the intersection only, just replace the OR function with the AND function:

=AND($B5=LOOKUP(width,widths),B$5=LOOKUP(height,heights))

Explanation

In this example, the goal is to highlight empty cells in the range C5:J16 with conditional formatting. This is a quick and easy way to locate missing values in a data set. To apply a conditional formatting rule to highlight empty cells, follow these steps:

  1. Select the range that contains empty cells you want to highlight (C5:J16 in this case).
  2. On the Home tab of the ribbon, click Conditional Formatting, then New Rule.
  3. In the list of options for rule type, select “Use a formula to determine which cells to format”.
  4. In the input area, add the following formula: =ISBLANK(C5)
  5. Click the Format button and configure the desired formatting.

The result should be a Conditional Formatting rule like this:

A conditional formatting rule to highlight blank cells - 1

When you use a formula to apply conditional formatting, the formula is evaluated relative to the active cell in the selection at the time the rule is created. So, in this case, the formula =ISBLANK(C5) is evaluated for each cell in C5:J16. Because C5 is entered as a relative address, the address will be updated each time the formula is applied, and ISBLANK() is run on each cell in the range. The TRUE or FALSE result for each cell is what triggers the rule.

Empty vs. blank

=LEN(C5)=0

The LEN function returns the length of a text string as a number. A cell that contains an empty string ("") will have a length of zero, so the formula will return TRUE for cells that are truly empty and cells that contain an empty string ("") returned by a formula.

Not blank

To conditionally format cells that are not blank, you can use a formula like this:

=NOT(ISBLANK(A1))

The NOT function reverses the logic.