↑ Return to Statistic

MOD

The MOD function returns the rest of a division. This function is useful for the conditional formatting, data validation or in a condition.

 

Presentation of the MOD function

Function_Mod_1If you try to divide 24 by 3, the result is 8. As the result is just whole number, the rest of the division is 0. With Excel, we write the function as follows

= MOD(24,3)

 

 

 

 

 

Function_Mod_2Now if we divide 24 by 5, the result of this division is not an integer. The rest of the division – or the modulo – will give as result

=MOD(24,5)

 

 

 

 


Example

You can find, for instance, if a number is a even or odd with this 2 formulas

 

Find the even number

=MOD(A2;2)=0

Find the odd number

=MOD(A2;2)<>0

 

 

 

 

 

And you can include this test in a IF function to display the result of your test

 

 

=IF(MOD(A2,2)=0,”Is even number”, “Is odd number”)

Leave a Reply

%d bloggers like this: