Conditional Formatting Every Other Row in Excel

How-to basics · Updated December 3, 2026

To apply conditional formatting to every other row in Excel for Microsoft 365 on Windows, select the rows or cells, choose Home > Conditional Formatting > New Rule > Use a formula to determine which cells to format, and enter =MOD(ROW(),2)=0. Choose a format and select OK; this shades even-numbered worksheet rows. Use =MOD(ROW(),2)=1 instead to shade odd-numbered rows.

How the alternating-row formula works

The formula checks each cell’s row number. ROW() returns the row number of the cell Excel is evaluating, and MOD(ROW(),2) returns the remainder after dividing that number by 2. Even rows have a remainder of 0, while odd rows have a remainder of 1. The condition after the equals sign tells conditional formatting which rows should receive the selected format.

For example, if the rule applies to A2:F20, row 2 is even and gets formatted by the first formula, row 3 is odd and does not, row 4 is even and gets formatted, and so on. The formula uses actual worksheet row numbers, not the row’s position within the selected range. That distinction matters when your selection starts below row 1.

To make the first row of a selection colored regardless of its worksheet position, use a formula that counts from the first row of the selection. If the range begins at row 2, for example, use =MOD(ROW()-ROW($A$2),2)=0. Apply that rule to the intended range. It colors rows 2, 4, 6, and so forth because row 2 is treated as position zero.

Apply the rule to a range

  1. Select the cells to format. For a table-like range, select all columns in the rows, such as A2:F20, so the shading extends across the full record.
  2. On the Home tab, choose Conditional Formatting > New Rule.
  3. Select Use a formula to determine which cells to format.
  4. Enter =MOD(ROW(),2)=0 to format even worksheet rows, or change 0 to 1 to format odd rows.
  5. Select Format, choose a fill color or other visual style, and select OK. Select OK again to create the rule.

Check the Applies to range in Conditional Formatting > Manage Rules if the formatting appears only in one column or misses rows. The formula determines which rows qualify, but Applies to determines where the appearance can be shown. For a range beginning in A2 and ending in F20, the intended Applies to entry is =$A$2:$F$20.

In the New Formatting Rule dialog, the formula should be entered as a condition, not typed into a worksheet cell. The rule evaluates it across the selected cells. Relative references such as ROW() adjust as Excel evaluates different rows, so there is no need to write a separate formula for each row.

Choose the right starting pattern

There are several useful variations, depending on what “every other row” means in your sheet:

  • Shade even worksheet rows: use =MOD(ROW(),2)=0. This always shades rows 2, 4, 6, and so on, even if the selected range starts elsewhere.
  • Shade odd worksheet rows: use =MOD(ROW(),2)=1. This shades rows 1, 3, 5, and so on.
  • Start with the first row of the selected data: if the selection begins in row 2, use =MOD(ROW()-ROW($A$2),2)=0. Replace A2 with a cell in the actual first row of the range.
  • Start with the second row of the selected data: for a range beginning in row 2, use =MOD(ROW()-ROW($A$2),2)=1.

The dollar signs in $A$2 lock the reference so it continues to point to the first row while the rule is evaluated elsewhere. The particular column in that reference is not important to the row calculation, but the row number must match the top row of the selected range.

Use a table style or conditional formatting?

For a structured list that you want to expand as you add records, an Excel Table is often simpler. Select a cell in the data and choose Insert > Table, confirm the range and whether it has headers, then select a style with banded rows. You can also use the Table Design tab to enable Banded Rows or choose another table style. New rows added to the table generally inherit its formatting.

Conditional formatting is more flexible when you want a custom color, when the range is not a table, or when the pattern depends on a formula or other values. It can also be used over a fixed worksheet area without converting the data to a table. However, when records are inserted or the data range grows, verify the rule’s Applies to range to ensure the new rows are included.

These approaches can overlap: table banding and conditional formatting may both apply to the same cells. If the result looks different from what you expect, inspect the table style and the rules under Home > Conditional Formatting > Manage Rules. Keeping one method for the same banding effect makes the appearance easier to control.

Common problems and fixes

  • The first shaded row is unexpected: the basic formula follows worksheet row numbers. Use the relative-to-start formula if the pattern should begin at the top of a selected range.
  • Only part of each row is shaded: expand the rule’s Applies to range across all desired columns.
  • The pattern stops too soon: edit the rule and extend Applies to, or use an Excel Table with banded rows for a growing list.
  • Existing colors remain visible: the rule may set only one formatting property, such as fill, while other direct formatting remains. Review the selected format and any competing conditional-formatting rules.
  • Alternation changes after sorting: a row-based rule shades positions, not particular records. Sorting moves records to different row numbers, so the banding follows the new positions. This is usually appropriate for readability.

Conditional formatting changes how cells look; it does not insert blank rows, change values, or permanently attach a color to a particular record. If color needs to identify a record even after sorting, use a value or category-based rule instead of alternating by row position.

Frequently Asked Questions

Can I highlight every other row without using a formula?
Yes. For a regularly expanding list, convert the range to an Excel Table with Insert > Table and select a style with banded rows. Conditional formatting is preferable when you need a custom formula-driven pattern.

Why does my rule start on the wrong row?
ROW() returns the worksheet row number. If your selection starts at row 5, the basic even-row formula begins by shading row 6, not the first selected row. Use a formula based on the selection’s first row to make the pattern start there.

Will the formatting update when I insert or delete rows?
Excel recalculates the row-based condition, so the alternating pattern adjusts to the new row positions. The Applies to range may also change with edits, but check it after adding data outside the existing range. A Table is a convenient option when the list regularly grows.

Can I alternate more than two colors?
Yes. Create multiple conditional-formatting rules using a repeating pattern. For three alternating row groups, for example, use =MOD(ROW(),3)=0, =MOD(ROW(),3)=1, and =MOD(ROW(),3)=2, assigning a different format to each rule and applying all three to the same range.

Does the formula work in Excel for Mac or Excel for the web?
The MOD and ROW functions are available in Excel for Mac and Excel for the web, and the conditional-formatting idea is the same. Dialog labels or menu placement can differ slightly from Microsoft 365 for Windows, so use the formula-rule option in the conditional-formatting controls for that version.

Related

Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.

More in How-to basics

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.