Alternate Row Shading Explained

dmarks3505

New Member
Joined
Nov 16, 2021
Messages
2
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I use the formula MOD(ROW(),2)=0 in conditional formatting, but when I try to explain it to others as to how the formula is built, I am at a loss. Would someone please explain the construction of the formula (what each part is doing)? When I look up the MOD formula in HELP, I don't understand how the alternate row shading is the result.
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
The MOD function returns the remainder when one number is divided by another. As you are dividing by 2 the mod will either be 1 or 0. So all even rows will return true & so are formatted.
 
Upvote 0
Hi dmarks3505,

MOD returns the remainder after dividing by the divisor, in this case 2.
ROW() returns the row number of the current cell.
If you are on row 1 then ROW() returns 1, MOD(1,2) returns 1 so checking =0 returns FALSE
If you are on row 6 then ROW() returns 6, MOD(6,2) returns 0 so checking =0 returns TRUE
 
Upvote 0
Solution
You could also use this formula which will give the same result
Excel Formula:
=ISEVEN(ROW())
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,223,984
Messages
6,175,786
Members
452,670
Latest member
nogarth

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top