How to Shade Alternate Row Colors in Excel
By ExcelReady TeamUpdated 5 min read
The short answer
The quickest way to shade alternate rows in Excel is to turn the data into a table with Ctrl+T (Mac: ⌘T), which adds banded rows automatically. For a normal range, select it, go to Home > Conditional Formatting > New Rule, choose "Use a formula", type =MOD(ROW(),2)=0 and pick a fill color. The bands stay correct when you sort.
Key takeaways
- Ctrl+T (Mac: ⌘T) turns data into a table with banded rows in one step.
- For a normal range, use the conditional formatting formula =MOD(ROW(),2)=0, or =ISEVEN(ROW()).
- =MOD(INT((ROW()-2)/3),2)=0 shades bands of three rows, starting from row 2.
- =MOD(SUBTOTAL(3,$A$2:$A2),2)=0 keeps the stripes even when rows are filtered out.
- Don't stripe by hand with fill color: the colors move with the data when you sort.
On this page+
To add alternate row colors in Excel, press Ctrl+T (Mac: ⌘T) to turn your data into a table, which shades every other row for you. If you'd rather keep a normal range, add a conditional formatting rule with the formula =MOD(ROW(),2)=0. Both stay correct when you sort or add rows. This guide covers both methods, plus bands of several rows, columns, filtered lists and how to remove the shading.
Why shade alternate rows?#
Banded rows, also called zebra stripes, help the eye follow a row across a wide table. They make it easier to read the right number in long lists, printed reports and screen shares.
Avoid painting the stripes by hand with the Fill Color button. Manual colors belong to the cells, so when you sort, filter or insert a row, the pattern breaks. Both methods below calculate the stripes, so they always line up.
Method 1: Format as a table (the fastest way)#
A table adds banded rows in one step.
- Click any cell inside your data.
- Press Ctrl+T (Mac: ⌘T), or go to Home > Format as Table and pick a style.
- Check that My table has headers is ticked and click OK.
Excel shades every other row. To change the look, click inside the table and use the Table Design tab:
- Table Styles: pick another color scheme.
- Banded Rows: tick or untick the stripes.
- Banded Columns: shade every other column instead, or as well.
Tables also grow when you add rows at the bottom, and the stripes follow. The guide to Excel tables and Ctrl+T covers the other benefits, such as formulas that fill down by themselves.
If you need a plain range again, use Table Design > Convert to Range. The colors stay, but they become fixed formatting, so they won't adjust when you sort or insert rows.
Method 2: Conditional formatting with MOD and ROW#
A conditional formatting rule shades rows on any range, without making a table. It's the method to use when a table isn't allowed or when you need a custom pattern.
- Select the data rows, for example A2:E50 (leave out the header).
- Go to Home > Conditional Formatting > New Rule.
- Choose Use a formula to determine which cells to format.
- Type this formula:
=MOD(ROW(),2)=0- Click Format, open the Fill tab, pick a light color and click OK twice.
Every even row is now shaded: rows 2, 4, 6 and so on.
How it works: ROW() returns the row number of each cell, and MOD(number,2) returns the remainder after dividing by 2. Even rows have a remainder of 0, so the rule is TRUE and Excel applies the fill. For row 4, MOD(4,2) is 0; for row 5, it's 1. The MOD and INT guide explains MOD in more detail.
To shade the odd rows instead, use =MOD(ROW(),2)=1. The shorter =ISEVEN(ROW()) and =ISODD(ROW()) work too.
Shade bands of several rows or every nth row#
You can change the pattern by changing the maths.
| Pattern | Formula | Rows shaded (data starting in row 2) |
|---|---|---|
| Every other row | =MOD(ROW(),2)=0 | 2, 4, 6, 8 … |
| Every third row | =MOD(ROW(),3)=0 | 3, 6, 9 … |
| Bands of 3 rows | =MOD(INT((ROW()-2)/3),2)=0 | 2–4, 8–10, 14–16 … |
| Every other column | =MOD(COLUMN(),2)=0 | Columns B, D, F … |
The bands formula works in three steps. ROW()-2 makes the first data row count as 0. Dividing by 3 and taking the INT gives the same number for each group of three rows: 0 for rows 2 to 4, 1 for rows 5 to 7. Then MOD checks whether that group number is even. Change both 2s if your data starts on a different row, and the 3 for a different band size.
Keep the stripes when you filter#
The ROW-based rule uses real row numbers, so when a filter hides rows, two shaded or two plain rows can end up next to each other. To stripe only the visible rows, use SUBTOTAL:
=MOD(SUBTOTAL(3,$A$2:$A2),2)=0SUBTOTAL(3,…)is COUNTA that ignores rows hidden by a filter.$A$2:$A2grows one row at a time as the rule moves down. The first$A$2is locked and the second$A2has an unlocked row, so in row 10 it reads$A$2:$A10.- The count goes 1, 2, 3 … down the visible rows, and MOD shades every second one.
Column A must have a value in every row for the count to be right. Use an ID or name column that is never blank.
Shade rows by group instead of by count#
Sometimes you want the color to switch when a value changes, such as each new date or customer. A helper column makes this easy. With the group in column A and data from row 2:
- In F2, type
1. - In F3, type
=IF(A3=A2,F2,1-F2)and fill down. - Add a conditional formatting rule on A2:E50 with
=$F2=1.
The helper flips between 1 and 0 each time column A changes, and the rule shades every row where it's 1. The data must be sorted by the group column. The $ before F keeps every cell in the row looking at column F, the same trick used to highlight a whole row based on one cell.
Edit or remove alternate row shading#
To change a conditional formatting rule, select a cell in the range and go to Home > Conditional Formatting > Manage Rules. There you can edit the formula, the color or the Applies to range.
To remove the shading:
- Rule: select the range and choose Conditional Formatting > Clear Rules > Clear Rules from Selected Cells, or from Entire Sheet.
- Table: untick Banded Rows on the Table Design tab, or pick the None style at the top-left of the style gallery.
If your rule doesn't work, check three things: the formula starts with =, the Applies to range starts on the row you expect, and no other rule with a different fill is above it in the list. The guides to conditional formatting with formulas and conditional formatting basics cover rule order and more examples.
Practise it#
Banding is one formula rule, and the same skill colors whole rows by status, date or value. Practise conditional formatting in a live spreadsheet: you highlight values, duplicates and the top 3, then color whole rows with a formula rule. Then practise more formatting to tidy number and date styles. Try the exercise on this page to see exactly what the banding rule returns for a row.
Try it yourself
This is a live spreadsheet. Type the formula in the green cell and press Enter.
Conditional formatting shades a row when its rule returns TRUE. Click E4 and type the banding rule =MOD(ROW(),2)=0 to see what Excel checks for row 4, then press Enter.
| A | B | C | D | E | F | |
|---|---|---|---|---|---|---|
| 1 | Amount | |||||
| 2 | ||||||
| 3 | ||||||
| 4 | Shade row 4? | |||||
| 5 | ||||||
| 6 | ||||||
| 7 | ||||||
| 8 | ||||||
| 9 |
Tip: ROW() gives the row number of the cell the formula is in. MOD(…,2) is 0 for even rows.
Practise this in a lesson
Frequently asked questions
How do I make every other row a different color in Excel?
Select the data, press Ctrl+T (Mac: ⌘T) and click OK to make a table, which shades alternate rows. Or use Home > Conditional Formatting > New Rule > Use a formula, type =MOD(ROW(),2)=0 and choose a fill color.
How do I alternate row colors without a table?
Use conditional formatting with a formula. Select the range, choose New Rule > Use a formula to determine which cells to format, type =MOD(ROW(),2)=0 and set a fill color. It works on any normal range.
How do I keep alternate row colors when filtering?
Use the rule =MOD(SUBTOTAL(3,$A$2:$A2),2)=0 instead of the ROW version. SUBTOTAL counts only visible rows, so the stripes alternate on what you can see. Column A must have a value in every row.
How do I remove alternate row shading in Excel?
For a table, untick Banded Rows on the Table Design tab or choose the None style. For a conditional formatting rule, select the range and use Home > Conditional Formatting > Clear Rules > Clear Rules from Selected Cells.
How do I shade every third row in Excel?
Use the conditional formatting formula =MOD(ROW(),3)=0. It shades rows 3, 6, 9 and so on. Change the 3 to shade every nth row.