Help Understanding MOD

KevCarter

Board Regular
Joined
Dec 7, 2013
Messages
161
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Last week @Fluff posted a great formula to use when conditional formatting multiple rows in succession. It works beautifully, but I am going crazy trying to understand why...

I understand how the MOD function works when the first argument given is greater than the divisor, but why does it work when the first argument is less than the divisor? It's driving me crazy trying to understand how the early pattern is developed. Here is a sample below. Again, it works perfectly, but why? :)

Thank you. I hope everyone is having a very happy holiday.

Cell Formulas
RangeFormula
A2:A16A2=MOD(ROWS(A$2:A2)-1,4)<2
B2:B16B2=MOD(ROWS(A$2:A2)-1,4)
C2:C16C2=MOD(ROWS(C$2:C2)-1,4)>=2
E2:E16E2=MOD(ROWS(E$2:E2)-1,6)<3
F2:F16F2=MOD(ROWS(E$2:E2)-1,6)
G2:G16G2=MOD(ROWS(E$2:E2)-1,6)>=3
I2:I16I2=MOD(ROWS(I$2:I2)-1,8)<4
J2:J16J2=MOD(ROWS(I$2:I2)-1,8)
K2:K16K2=MOD(ROWS(I$2:I2)-1,8)>=4
M2:M16M2=MOD(ROWS(I$2:I2)-1,10)<5
N2:N16N2=MOD(ROWS(I$2:I2)-1,10)
O2:O16O2=MOD(ROWS(I$2:I2)-1,10)>=5
Cells with Conditional Formatting
CellConditionCell FormatStop If True
O2:O101Expression=MOD(ROWS(I$2:I2)-1,10)>=5textNO
M2:N101Expression=MOD(ROWS(I$2:I2)-1,10)<5textNO
K2:K101Expression=MOD(ROWS(I$2:I2)-1,8)>=4textNO
I2:J101Expression=MOD(ROWS(I$2:I2)-1,8)<4textNO
G2:G101Expression=MOD(ROWS(E$2:E2)-1,6)>=3textNO
E2:F101Expression=MOD(ROWS(E$2:E2)-1,6)<3textNO
C2:C101Expression=MOD(ROWS(C$2:C2)-1,4)>=2textNO
A2:B101Expression=MOD(ROWS(A$2:A2)-1,4)<2textNO
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
I'm not sure I understand what your question is, but the MOD function is equivalent to doing division when you first learned it which was before you learned about decimal notation. For example, if you were given the problem in grade school of 17 divided by 5, you would return the answer 3 with a remainder of 2... the remainder is what MOD returns.
 
Upvote 0
I'm not sure I understand what your question is, but the MOD function is equivalent to doing division when you first learned it which was before you learned about decimal notation. For example, if you were given the problem in grade school of 17 divided by 5, you would return the answer 3 with a remainder of 2... the remainder is what MOD returns.
Hello Rick,

So the part I don't understand. Let's say we are in cell A3, we are dividing 1/4 (I think?), so the first number is less than the divisor. I have never understood math very well, and I can't figure out how 1/4 gets a remainder of 2. I'm just really confused...

Thank You,
Kevin
 
Upvote 0
In your example, are you asking for MOD(1,4) ? If so, the answer is 1, not 2. From grade school, when you divide 1 by 4, the answer is 0 (because 4 does not go into 1) with a remainder of 1. By the way, for completeness, Excel's MOD function does more than what I have described, that is, it can do more than return the divisor from a division... you don't need that extra functionality for what you are doing, but I didn't want to leave that unsaid for possible future readers of this thread.
 
Upvote 0
Solution
In your example, are you asking for MOD(1,4) ? If so, the answer is 1, not 2. From grade school, when you divide 1 by 4, the answer is 0 (because 4 does not go into 1) with a remainder of 1. By the way, for completeness, Excel's MOD function does more than what I have described, that is, it can do more than return the divisor from a division... you don't need that extra functionality for what you are doing, but I didn't want to leave that unsaid for possible future readers of this thread.
Oops, I mis-typed. Thank you Rick.
 
Upvote 0
Now I see the pattern Rick. If the first number is lower than the divisor, MOD just gives you that first number back. I didn't understand your reply at first. I'm so dense. Thank you for your help Sir!

Kevin
 
Upvote 0
I'm not sure I understand what your question is, but the MOD function is equivalent to doing division when you first learned it which was before you learned about decimal notation. For example, if you were given the problem in grade school of 17 divided by 5, you would return the answer 3 with a remainder of 2... the remainder is what MOD returns.
These values are in the referenced cells please explain the formula
1236373839
=SUMPRODUCT((MOD($B495043:$E495043-1,10)<3)*(MOD($C495043:$F495043-1,10)<3))&SUMPRODUCT((MOD($B495043:$E495043-1,10)>=3)*(MOD($C495043:$F495043-1,10)>=3))&SUMPRODUCT((MOD($B495043:$E495043-1,10)<3)*(MOD($C495043:$F495043-1,10)>=3))&SUMPRODUCT((MOD($B495043:$E495043-1,10)>=3)*(MOD($C495043:$F495043-1,10)<3))
 
Upvote 0
@CARBOB as this is a totally different question from the OP's please start a thread of your own. Thanks
 
Upvote 0

Forum statistics

Threads
1,213,534
Messages
6,114,184
Members
448,554
Latest member
Gleisner2

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