Home  /  Blog  /  Logical & Conditional
Logical & Conditional

Shade Every Other Row in Excel — With Examples (MOD, ROW, Banded Rows)

By admin 1 December 2026 Logical & Conditional

Your table is wide, the rows run together, and your eyes lose their place halfway across. Shading every other row fixes it — a light band on every second row, so each row is easy to follow. The fastest way is one click: Ctrl+T turns the data into a table, and Excel shades the rows for you. The flexible way is one formula: =MOD(ROW(),2)=0 as a conditional formatting rule, which shades the even rows. This guide gives you both, then runs the formula on the ten-order sales table, so you can count which rows shade — even, odd, every third, every fourth and every fifth — plus the filter fix that keeps the stripes when you filter, and how to remove the shading.

Quick takeaway: one click, or one formula.

  • One click: click a cell in the data, press Ctrl+T, click OK — Excel shades every other row automatically.
  • One formula: =MOD(ROW(),2)=0 — even rows shade. =MOD(ROW(),2)=1 — odd rows shade.
  • ROW() is the row number; MOD() is the remainder after dividing by 2.
  • Every third row: =MOD(ROW(),3)=0. Every fourth: =MOD(ROW(),4)=0.
  • Filtering breaks the plain formula — use SUBTOTAL to count only the visible rows.
Shade Every Other Row in Excel — With Examples (MOD, ROW, Banded Rows)

The Fastest Way — Turn It Into a Table (Ctrl+T)

  1. Click any cell in the data.
  2. Press Ctrl+T (or go to Insert > Table), and click OK.
  3. Excel shades every other row automatically — that is the Banded Rows option on the Table Design tab.

The big plus of a table: the banding continues automatically when you add or delete rows in the table. Want a different colour? Click any cell in the table, go to Table Design, and pick another style in the Table Styles gallery. You can also get it straight from Home > Format as Table. Do not want a table? Use the formula instead — it gives you full control over the colour, and it works on any range.

The Formula Way — MOD and ROW

  1. Select the whole data range where you want the shading — A2:F11 in the table below.
  2. Go to Home > Conditional Formatting > New Rule.
  3. Choose “Use a formula to determine which cells to format”.
  4. Type the formula: =MOD(ROW(),2)=0.
  5. Click Format, pick a fill colour on the Fill tab, and click OK twice.

What does the formula mean? ROW() returns the row number of the cell — =ROW() in cell A2 returns 2. MOD() returns the remainder after a division — =MOD(5,2) returns 1, because 2 goes into 5 two times (4) and 1 is left over. So =MOD(ROW(),2)=0 divides each row number by 2 and checks if the remainder is 0 — that is TRUE for all even rows, so all even rows get shaded. The beauty of this method: even if you delete a row in the table, the banding is maintained automatically, because the formula reads the row numbers, not the data.

The Worked Table — Which Rows Shade

Every example below uses the same ten-order sales table from the COUNTIF, SUMIF and Highlight Row articles — Rep, Region, Sales, Order Date, Status, Notes — in rows 2 to 11. Every shaded row was counted against it.

RuleFormulaRows shadedCount
Even rows=MOD(ROW(),2)=02, 4, 6, 8, 105
Odd rows=MOD(ROW(),2)=13, 5, 7, 9, 115
Every 3rd row=MOD(ROW(),3)=03, 6, 93
Every 3rd row, offset=MOD(ROW(),3)=14, 7, 103
Every 3rd row, other offset=MOD(ROW(),3)=22, 5, 8, 114
Every 4th row=MOD(ROW(),4)=04, 82
Every 5th row=MOD(ROW(),5)=05, 102

Read the rows. The even and odd rules shade 5 rows each — the ten data rows split evenly. The every-third-row rules show the offset: =0 shades rows 3, 6 and 9, =1 shades 4, 7 and 10, and =2 shades 2, 5, 8 and 11 — four rows, because the range starts on row 2, which leaves remainder 2. And the every-fourth rule shades only 2 rows, 4 and 8 — the range is only ten rows long, so the pattern barely repeats.

Shade Every Other Column Instead

The same formula works sideways — swap ROW() for COLUMN():

=MOD(COLUMN(),2)=0

That shades the even columns — B, D and F in the table. Use it for the same reason: a wide table where the columns run together. And the same offsets work: =MOD(COLUMN(),2)=1 shades the odd columns, A, C and E.

When You Filter — The Stripes Break, and the Fix

The plain formula shades by row number, so when you filter, the visible rows keep their original even-or-odd shading and the stripes break. Filter the table to hide the four Pending orders — rows 3, 6, 8 and 10 — and the visible rows are 2, 4, 5, 7, 9 and 11. The plain rule =MOD(ROW(),2)=0 shades only rows 2 and 4 of those, so the first two visible rows are both shaded and the last four are not — the stripes are gone.

The fix is SUBTOTAL, which counts only the visible rows:

=MOD(SUBTOTAL(3, $A$2:$A2), 2)=0

SUBTOTAL(3, …) counts the non-empty visible cells from A2 down to the current row, so it gives each visible row a fresh number — 1, 2, 3, 4, 5, 6 — and MOD(…,2)=0 shades the even ones of those. On the filtered table that shades rows 4, 7 and 11 — the 2nd, 4th and 6th visible rows — and the stripes are back. The $ locks are on the start of the range ($A$2) and the column of the end ($A2) — the end row has no $, so the range grows as Excel works down the table.

The VBA Way — One Macro, No Rule

If you want the shading painted in, not as a rule — for a file you send to someone who will not keep the rule — a short macro does it:

Sub ShadeEveryOtherRow()
    Dim i As Long
    For i = 2 To 11 Step 2
        Rows(i).Interior.Color = RGB(221, 235, 247)
    Next i
End Sub

That colours rows 2, 4, 6, 8 and 10 — the same five even rows as the formula. The difference: the macro paints the colour once, so it does not update when rows are added or deleted, and it cannot be undone with Ctrl+Z after the file is saved. Use the formula for a living table; use the macro for a one-off print.

How to Remove the Shading

What you usedHow to remove it
Table banding (Ctrl+T)Click a cell in the table, go to Table Design, and untick Banded Rows — or convert the table back with Table Design > Convert to Range
Conditional formatting ruleSelect the range, Home > Conditional Formatting > Clear Rules > Clear Rules from Selected Cells
VBA-painted colourSelect the range and set the fill to No Fill, or run the macro again with RGB(255, 255, 255)

Common Mistakes

MistakeWhat happensFix
You shaded by hand, row by rowAdding or deleting a row breaks the patternUse the table or the formula — both update themselves
You used =MOD(ROW(),2)=1 expecting even rowsThe odd rows shade — the table starts on row 2, so the first data row is evenUse =0 for even rows, =1 for odd rows
You selected only one columnOnly that column shadesSelect the whole range, A2:F11, before creating the rule
You added data below the rangeThe new rows have no shadingExtend the rule’s Applies to range, or use a table, which extends itself
You filtered and the stripes brokeVisible rows keep their original even-or-odd shadingUse the SUBTOTAL formula
You used the macro for a living tableThe shading does not update when rows changeUse the conditional formatting rule instead

Frequently Asked Questions

How do I shade every other row in Excel? Click a cell in the data, press Ctrl+T and click OK — Excel shades every other row automatically. Or use conditional formatting with =MOD(ROW(),2)=0.

What is the formula for alternate row shading? =MOD(ROW(),2)=0 — ROW() gives the row number, MOD() gives the remainder after dividing by 2, and =0 is TRUE for even rows. =MOD(ROW(),2)=1 shades the odd rows.

How do I shade every third row? =MOD(ROW(),3)=0 — on the ten-order table that shades rows 3, 6 and 9. Change the 3 to a 4 for every fourth row, and so on.

How do I shade every other column? =MOD(COLUMN(),2)=0 — the same formula, sideways. It shades the even columns.

Why do the stripes break when I filter? The plain formula shades by row number, so hidden rows keep their place in the pattern. Use =MOD(SUBTOTAL(3, $A$2:$A2), 2)=0 instead — SUBTOTAL counts only the visible rows.

How do I remove alternate row shading? For a table, untick Banded Rows on the Table Design tab. For a rule, Clear Rules from Selected Cells. For VBA-painted colour, set the fill to No Fill.

That is how to shade every other row in Excel: Ctrl+T is one click and Excel does it for you, with banding that grows when the table grows — and =MOD(ROW(),2)=0 is one formula that gives you full control over the colour, with =1 for the odd rows and =MOD(ROW(),3)=0 for every third row. On the ten orders in this guide, the even rule shades rows 2, 4, 6, 8 and 10, the odd rule shades 3, 5, 7, 9 and 11, and the every-third rule shades 3, 6 and 9. Remember the two things that catch everyone once: the plain formula shades by row number, so filtering breaks the stripes — SUBTOTAL counts only the visible rows — and a table extends itself when you add data, while a conditional formatting rule has to be extended by hand. From here, the next functions worth learning are the ones this one sits next to — the highlight row guide for shading a row by its value, the IF formula for the logic inside a rule — and the full learning order for the whole site is on the Excel Formulas hub and the Logical & Conditional category page.


About admin

Author of Excel formula guides on this blog.

View all guides by admin →

Keep Learning

Related guides