In this post, you’ll learn about the Mod operator and how to use Mod operator to solve mathematical problems spreadsheets using Excel VBA.
The MOD function returns the remainder of the divided numbers.
Sample program using Mod operator in Excel VBA.
- First, place a command button on your worksheet.
- Add the following code to the button.
Private Sub CommandButton1_Click() Dim Result As Integer Result = 57 Mod 12 MsgBox Result End Sub
Now run the code or click the command button. The result gets displayed.