Mod Operator in Excel VBA

In this post, you’ll learn about the Mod operator and how to use Mod operator to solve mathematical problems spreadsheets using Excel VBA.   

Mod Operator

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.

Code:

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.

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

In this post, you’ll learn how to Find Blank cells in excel so that you can remove or delete the blank cells form...
In this article, you’ll learn what is a Gauge Chart in Microsoft Excel. Also, you will learn how to add...
Microsoft Excel provides a shortcut for the users to move columns in excel using two different ways – using Shift...