Banded rows are easy — but when data is grouped, you want the shading to change with each group, not every other row. A running count of group changes makes the bands line up with the data.
The example
Rows grouped by region; each region gets one shade.
| A | B | C | |
|---|---|---|---|
| 1 | Region | Rep | Grp # |
| 2 | East | Ann | 1 |
| 3 | East | Bo | 1 |
| 4 | West | Cy | 2 |
| 5 | North | Di | 3 |
The formula
A helper column counts groups; the rule shades odd ones:
How it works
The trick is a group counter, then shade by whether it’s odd:
- Make sure the data is sorted by the grouping column so each group is contiguous.
- Add a helper in C2:
=IF(A2=A1, C1, C1+1)— it keeps the same number within a group and bumps up by 1 at each change. Start C1 at 0 or a header. - Select the table and add the rule
=ISODD($C2)(column locked) to shade every odd-numbered group. - Hide the helper column. Now each group — whatever its size — is one solid band, alternating shade by shade.
No helper column? A self-contained rule uses SUMPRODUCT to count distinct groups above the row: =ISODD(SUMPRODUCT((($A$2:$A2<>$A$1:$A1))*1)). It’s slower on big sheets, but keeps the sheet clean.
Try it: interactive demo
Edit regions (one per line, grouped); bands follow the groups.
Variations
Helper-free (SUMPRODUCT)
Count group changes inline:
Plain banded rows
If you just want every other row:
Band every N rows
Groups of 3, say:
Pitfalls & errors
Data must be sorted by group. If the grouping column isn’t grouped together, the bands will fragment. Sort first.
Lock the helper column. Use $C2 so every cell in a row reads that row’s group number; a relative C2 shifts across columns.
SUMPRODUCT version is slow. The helper-free formula recalculates a growing range per row — fine for hundreds of rows, sluggish for tens of thousands.
Practice workbook
Frequently asked questions
How do I shade alternating groups instead of alternating rows in Excel?
Can I do it without a helper column?
How do I just band every other row?
Stop fighting formulas. Learn them in a day.
This recipe is one of hundreds of real-world formulas we teach. Our Excel Formulas & Functions class covers lookups, logic, text, and dynamic arrays hands-on — live in Dallas–Fort Worth, Houston, Austin, Oklahoma City, Denver, or online.
See the Formulas & Functions Class