How to Flag Every Nth Row for Banded Formatting in Excel in 2026

Need to flag every nth row for banded formatting in Excel, such as every 3rd, 5th, or 10th row? The built-in Table Styles only alternate every other row, so a custom pattern takes a small helper formula plus one conditional formatting rule. The whole setup takes about five minutes and adjusts automatically when the spacing changes.

Key Takeaways

  • Store the spacing number (n) in its own cell so the pattern can be changed in seconds.
  • A helper column with an IF and MOD formula returns 1 for every nth row and 0 for the rest.
  • One conditional formatting rule that checks the helper column paints the flagged rows.
  • Lock the column letter with a dollar sign so the whole row is colored, not just one cell.

Step-by-Step Guide to Flag Every Nth Row for Banded Formatting in Excel

The example below assumes headers in row 1, data in A2:D100, a helper column in column E, and the spacing value in cell H2. Cell positions can be changed to fit any worksheet.

Part 1: Build the Flag Column

  • Step 1: Type a spacing label such as Every nth row in cell H1, then enter the number in cell H2. For example, type 3 to flag every third row.
  • Step 2: Type Flag in cell E1 as the helper column header.
  • Step 3: Click cell E2 and enter this formula: =IF(MOD(ROW()-ROW($E$1),$H$2)=0,1,0)
  • Step 4: Press Enter, then double-click the fill handle (the small square at the bottom-right corner of E2) to copy the formula down to the last data row. Rows 4, 7, 10, and so on now show 1, and every other row shows 0.

Part 1_ Build the Flag Column

Tip: Think of the formula as a person counting off rows at a party. ROW()-ROW($E$1) gives each data row its position number, and MOD hands back a zero every time that number lands on a multiple of n.

Part 2: Apply the Banded Formatting

  • Step 5: Select the range to format, for example A2:E100, starting the selection from A2 so that A2 is the active cell.
  • Step 6: On the Home tab, click Conditional Formatting, then choose New Rule.
  • Step 7: Select ‘Use a formula to determine which cells to format’.
  • Step 8: In the formula box, enter: =$E2=1
  • Step 9: Click Format, open the Fill tab, pick a background color, and click OK.
  • Step 10: Click OK again to apply the rule. Every nth row is now shaded across the full width of the range.

Part 2_ Apply the Banded Formatting

Part 3: Change the Spacing Later

  • Step 11: Type a new number in cell H2, such as 5. The flags and the shading update immediately, with no need to touch the rule again.
  • Step 12: To keep the sheet tidy, right-click the column E header and choose Hide. The rule still works because it reads the hidden values.

Tip: Pick a soft fill such as light gray or pale blue. Strong colors look fine on three rows but become tiring to read across a few hundred.

Common Problems and Fixes

Every row is shaded

This happens when the spacing cell contains 1, because every row is a multiple of 1. Enter 2 or higher in cell H2.

The helper column shows #DIV/0!

MOD cannot divide by zero, so an empty or zero value in H2 triggers this error. Enter a whole number of 2 or more in the spacing cell.

Only one column is shaded

The dollar sign before the column letter is missing. Open Conditional Formatting, choose Manage Rules, edit the rule, and make sure the formula reads =$E2=1 rather than =E2=1.

The wrong rows are shaded

The formula was probably entered while a cell other than the top-left cell of the range was active, which shifts the reference by a row. Edit the rule in Manage Rules and confirm the formula points to the first data row, such as $E2 for a range starting in row 2.

The pattern looks broken after filtering

The ROW-based formula counts hidden rows too, so a filtered list can look uneven. Replace the formula in E2 with =IF(MOD(SUBTOTAL(103,$A$2:$A2),$H$2)=0,1,0) and fill it down, so only visible rows are counted. Reapply the filter afterward if the shading does not refresh.

New rows at the bottom are not shaded

The rule only covers the range it was applied to. Open Conditional Formatting, choose Manage Rules, and extend the Applies to range, for example to $A$2:$E$500. The helper formula also needs to be filled down into the new rows.

Frequently Asked Questions

Can the same result be achieved without a helper column?

Yes. A conditional formatting rule with the formula =MOD(ROW()-ROW($A$1),$H$2)=0 shades every nth row directly. A helper column is easier to audit, though, because the 1s and 0s show exactly which rows are flagged.

How do I flag every 2nd row instead?

Enter 2 in the spacing cell. The flag column then returns 1 on rows 3, 5, 7, and so on, matching a standard alternating pattern.

How do I start the pattern on the first data row instead of the nth row?

Change the formula to =IF(MOD(ROW()-ROW($E$1)-1,$H$2)=0,1,0). The first data row is then flagged, followed by every nth row after it.

Will the shading follow the rows when the data is sorted?

The shading is tied to row position, not to the data itself. After sorting, the same row numbers stay shaded while the data moves underneath them.

Can the flagged rows get a font color or bold style instead of a fill?

Yes. In the Format Cells dialog opened from the rule, use the Font tab to set bold or a text color, and use the Fill tab only if a background is also wanted.

How do I remove the banding later?

Select the formatted range, click Conditional Formatting on the Home tab, choose Clear Rules, then pick Clear Rules from Selected Cells. The helper column can then be deleted.

Does the rule work if the helper column is hidden?

Yes. Conditional formatting reads the values in hidden columns, so column E can be hidden without affecting the shading.

Why does the formula use ROW() instead of typing row numbers by hand?

ROW() recalculates automatically as rows are added or removed, so the pattern stays correct without manual numbering.