SUMIFS Function in Excel — With Examples (Multiple Criteria, Dates, Wildcards)
Learn the SUMIFS function in Excel: sum with multiple criteria, date ranges, wildcards, and the SUMIF argument order trap.
Read Guide →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.
=MOD(ROW(),2)=0 — even rows shade. =MOD(ROW(),2)=1 — odd rows shade.=MOD(ROW(),3)=0. Every fourth: =MOD(ROW(),4)=0.
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.
=MOD(ROW(),2)=0.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.
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.
| Rule | Formula | Rows shaded | Count |
|---|---|---|---|
| Even rows | =MOD(ROW(),2)=0 | 2, 4, 6, 8, 10 | 5 |
| Odd rows | =MOD(ROW(),2)=1 | 3, 5, 7, 9, 11 | 5 |
| Every 3rd row | =MOD(ROW(),3)=0 | 3, 6, 9 | 3 |
| Every 3rd row, offset | =MOD(ROW(),3)=1 | 4, 7, 10 | 3 |
| Every 3rd row, other offset | =MOD(ROW(),3)=2 | 2, 5, 8, 11 | 4 |
| Every 4th row | =MOD(ROW(),4)=0 | 4, 8 | 2 |
| Every 5th row | =MOD(ROW(),5)=0 | 5, 10 | 2 |
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.
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.
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.
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.
| What you used | How 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 rule | Select the range, Home > Conditional Formatting > Clear Rules > Clear Rules from Selected Cells |
| VBA-painted colour | Select the range and set the fill to No Fill, or run the macro again with RGB(255, 255, 255) |
| Mistake | What happens | Fix |
|---|---|---|
| You shaded by hand, row by row | Adding or deleting a row breaks the pattern | Use the table or the formula — both update themselves |
You used =MOD(ROW(),2)=1 expecting even rows | The odd rows shade — the table starts on row 2, so the first data row is even | Use =0 for even rows, =1 for odd rows |
| You selected only one column | Only that column shades | Select the whole range, A2:F11, before creating the rule |
| You added data below the range | The new rows have no shading | Extend the rule’s Applies to range, or use a table, which extends itself |
| You filtered and the stripes broke | Visible rows keep their original even-or-odd shading | Use the SUBTOTAL formula |
| You used the macro for a living table | The shading does not update when rows change | Use the conditional formatting rule instead |
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.
Learn the SUMIFS function in Excel: sum with multiple criteria, date ranges, wildcards, and the SUMIF argument order trap.
Read Guide →Learn Excel comparison operators: equal, not equal, greater than, less than, and between two numbers, in IF, COUNTIF and SUMIF.
Read Guide →Learn the Excel formula for if a cell contains specific text: ISNUMBER with SEARCH, FIND for case, and COUNTIF wildcards.
Read Guide →