Vba
VBA Controls: VBA Form Control & ActiveX Controls in Excel
Creating VBA Form/GUI controls in Excel GUI is the acronym for Graphical User Interface. The GUI...
VBA Arithmetic Operators are used to perform arithmetic operations such as adding, subtracting, dividing or multiplying numbers.
The following table shows the VBA mathematical operators
| S/N | Operator | Description | Example | Output |
|---|---|---|---|---|
| 1 | + | Addition: This operator is used to add up numbers | 2 + 2 | 4 |
| 2 | - | Subtraction: This operator is used to subtract numbers | 5 - 3 | 2 |
| 3 | * | Multiplication: This operator is used to multiply numbers | 3 * 2 | 6 |
| 4 | / | Division: This operator is used to divide numbers | 9 / 3 | 3 |
| 5 | ^ | Exponentiation: This operator is used to raise a number to the power of another number | 2^3 | 8 |
| 6 | mod | Modulus Operator: Divides a number and returns the remainder | 10 mod 3 | 1 |
Add a button to the Excel sheet as we show earlier, and then follow the following points
Enter the following code in between Private Sub btnAdd_Click() and End Sub
Let's now execute our code
On the ribbon bar, look for the button Design Mode
If the button is in active state (green background colour), then it's in design mode. You cannot execute code in this state. If it is not in the active state (white background color), then it allows you to run the code.
Click on Design Mode button
The button should now appear as follows
Click on Add operator
You will get the following results
The best way to learn is by practicing. Follow the above steps to create buttons for subtraction, division, multiplication and exponentiation.
Write the code for the buttons and test them to see if the code executes.
Creating VBA Form/GUI controls in Excel GUI is the acronym for Graphical User Interface. The GUI...
What is Data Scraping? Data scraping is the technique that helps in the extraction of desired...
VBA Comparison Operators These are operators that are used to compare values. Comparison operators...
What is an Excel Macro? Excel Macro is a record and playback tool that simply records your Excel...
Download PDF Following are frequently asked questions in interviews for freshers as well...
This Excel VBA tutorial for beginners covers in-depth lessons to learn VBA Excel and VBA basics....