The Mod operator in Excel VBA gives the remainder of a division.
Place a command button on your worksheet and add the following code line:
Result when you click the command button on the sheet:
Explanation: 7 divided by 2 equals 3 with a remainder of 1.
Explanation: 8 divided by 2 equals 4 with a remainder of 0.
For a practical example of the mod operator, see our example program Prime Number Checker.