Excel tutorial
/

Data analysis

Advanced

Managing conditional formatting rules in Excel: formula rules, the $ sign and Stop If True

The Conditional Formatting Rules Manager: highlight whole rows with a formula (=$C2>100), the $ sign trap, rule order, Stop If True and Applies to.

Built-in rules (Greater Than, Top 10, Data Bars) format only the cell itself. Real work usually asks for something else: “make the whole row green when the order is over 100 mln”, “grey out cancelled orders and don’t draw a data bar for them”.

That takes two skills: writing formula-based rules and using the Conditional Formatting Rules Manager, where every rule on the sheet is listed in one place. This is the “professional” side of conditional formatting.

Книга1 - Excel
—☐✕
fx
ABCDE
1ClientCityAmount, mlnStatus
2AzizTashkent120Delivered
3DilnozaSamarkand85In transit
4JavohirBukhara150Cancelled
5MalikaTashkent60Delivered
6SardorNamangan101In transit
7NodiraAndijan95Delivered
8
Готово
Three rules: cancelled — grey with no data bar, over 100 mln — whole row green, column C — data bars

Opening the Rules Manager

1

Главная → Условное форматирование → Manage Rules....

Книга1 - Excel
—☐✕
ФайлГлавнаяВставкаРазметка страницыФормулыДанныеРецензированиеВидСправка
Вставить
Буфер обмена
Calibri ▾11 ▾
Шрифт
Выравнивание
Общий ▾
Число
Условное форматированиеФорматировать как таблицуСтили ячеек
Стили
ВставитьУдалитьФормат
Ячейки
АвтосуммаСортировка и фильтрНайти и выделить
Редактирование
A2fxAziz
ABCDE
1ClientCityAmount, mlnStatus
2AzizTashkent120Delivered
3DilnozaSamarkand85In transit
4JavohirBukhara150Cancelled
5
Готово

2

In Show formatting rules for, choose This Worksheet. By default only the rules of the selected cells are shown — which is why so many people think a rule “disappeared”.

Книга1 - Excel
—☐✕
A2fxAziz
ABCDE
1ClientCityAmount, mlnStatus
2AzizTashkent120Delivered
3DilnozaSamarkand85In transit
4JavohirBukhara150Cancelled
5
Готово

3

Each row shows: Rule — the condition, Format — what it looks like, Applies to — the range it affects, Stop If True — a box that halts the rules below. You can edit Applies to right here — no need to recreate the rule.

Highlighting a whole row with a formula

1

Select the table starting from A2, going down and right: A2:D7. The active cell must be A2 — the formula is written for that cell.

Книга1 - Excel
—☐✕
A2fxAziz
ABCDE
1ClientCityAmount, mlnStatus
2Aziz1Tashkent120Delivered
3DilnozaSamarkand85In transit
4JavohirBukhara150Cancelled
5MalikaTashkent60Delivered
6SardorNamangan101In transit
7NodiraAndijan95Delivered
8
ГотовоСреднее: 101,8333Количество: 24Сумма: 611

2

Условное форматирование → New Rule... → Use a formula to determine which cells to format. Type =$C2>100 in the box.

Книга1 - Excel
—☐✕
A2fxAziz
ABCDE
1ClientCityAmount, mlnStatus
2AzizTashkent120Delivered
3DilnozaSamarkand85In transit
4JavohirBukhara150Cancelled
5MalikaTashkent60Delivered
6SardorNamangan101In transit
7NodiraAndijan95Delivered
8
ГотовоСреднее: 101,8333Количество: 24Сумма: 611

3

Format... → on the Fill tab pick light green, on the Font tab dark green → OK → OK.

4

Result: every row with more than 100 in column C is filled end to end.

Книга1 - Excel
—☐✕
fx
ABCDE
1ClientCityAmount, mlnStatus
2AzizTashkent120Delivered
3DilnozaSamarkand85In transit
4JavohirBukhara150Cancelled
5MalikaTashkent60Delivered
6SardorNamangan101In transit
7NodiraAndijan95Delivered
8
Готово

Why =$C2 — what the $ sign does

The formula is written for the active cell (A2), and Excel then “copies” it into every cell of the range — just like filling an ordinary formula. So references shift as usual:

  • =$C2>100 — correct. The $ locks the column: every cell in the row looks at column C. The row number has no $, so each row checks its own amount.
  • =C2>100 — A2 checks C2, B2 checks D2 (text!), C2 checks E2 (empty). You get random, patchy formatting.
  • =$C$2>100 — every cell looks at C2 only. Since C2 = 120, the whole table turns green.

The rule of thumb: $ before the column, none before the row.

Книга1 - Excel
—☐✕
fx
ABCDE
1ClientCityAmount, mlnStatus
2AzizTashkent1201Delivered
3DilnozaSamarkand85In transit
4JavohirBukhara150Cancelled
5MalikaTashkent60Delivered
6SardorNamangan101In transit
7NodiraAndijan95Delivered
8
Готово
Rule =$C$2>100: every cell looks only at C2 (120) — the whole table is green, even 60 and 85

Rule order and Stop If True

Rules in the manager are evaluated top to bottom. When two rules change the same property (say, fill color), the higher one wins. Properties that don’t clash (one sets fill, another sets bold) are applied together. Change the order with the Move Up / Move Down arrows in the dialog.

Stop If True means “if this condition is met, don’t evaluate the rules below for this cell”. In our example the “Cancelled” rule is at the top with Stop If True on. So Javohir’s row (150 mln) doesn’t turn green and C4 gets no data bar — a cancelled order doesn’t look like a real sale.

Книга1 - Excel
—☐✕
A2fxAziz
ABCDE
1ClientCityAmount, mlnStatus
2AzizTashkent120Delivered
3DilnozaSamarkand85In transit
4JavohirBukhara150Cancelled
5
Готово
The first rule is selected with Stop If True on — for cancelled rows the two rules below don’t run

Pro level: handy formula rules and “fragmented” rules

A formula rule just needs to return TRUE or FALSE, so any function works (for A2:D7 with A2 active):

  • =$C2=МАКС($C$2:$C$7) — the row with the largest order.
  • =СЧЁТЕСЛИ($A$2:$A$7;$A2)>1 — repeat clients.
  • =И($D2<>"Delivered";$E2<СЕГОДНЯ()) — overdue orders not yet delivered (E is the due date).
  • =ОСТАТ(СТРОКА();2)=0 — shade every other row (zebra stripes).

Fragmented rules. Copying and pasting rows, inserting and cutting split one rule into dozens of copies: =$A$2:$D$5, =$A$7:$D$9, =$A$12:$D$12... The file slows down and colors behave oddly. The cure: in the manager choose This Worksheet, remove the extra copies with Delete Rule, and set the remaining rule’s Applies to to the full range.

A pro habit: before putting a complex formula into a rule, test it in a helper column — the rows showing TRUE are the ones that will be formatted.

Try it in the simulator

Test the formula before creating the rule: type =$C2>100 in E2 and fill down to E7 — rows showing TRUE will turn green. Then type =И($C2>100;$D2<>"Cancelled") in F2, fill it down and see why Javohir gets FALSE.

Книга1 - Excel
—☐✕
Буфер обмена
Шрифт
Выравнивание
Число
Стили
Ячейки
Редактирование
✕✓fx
ABCDEFGHIJKLMNOPQRSTUVWX
1ClientCityAmount, mlnStatus> 100?Not cancelled and > 100?
2AzizTashkent120Delivered
3DilnozaSamarkand85In transit
4JavohirBukhara150Cancelled
5MalikaTashkent60Delivered
6SardorNamangan101In transit
7NodiraAndijan95Delivered
8
9
10
11
Лист1
Готово

Has ExcelLab been useful?

Support the project and help us release new lessons and exercises.

Support us
Previous

52 / 154