where data (B5:D15) and n (F5) are named ranges. This rule highlights the last n rows in the data. When n is changed, the highlighting is automatically updated. The formula uses the greater than operator (>) to check row in the data. On the left, the formula calculates a “current row”, normalized to begin at the number 1: On the right, the formula generates a threshold number: When the current row is greater than the threshold, the formula returns TRUE, triggering the conditional formatting.

Conditional formatting rule

The conditional formatting rule is set up to use a formula like this:

With a table

You can’t use a table name in a CF formula at present. However, you can select or enter the table data range when creating the formula in the CF window, and Excel will keep the reference up to date as the table expands or shrinks.

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.

Conditional formatting last n rows   Excel formula - 10