Activate the Control Toolbox
In order to use Excel VBA in Excel 2003, you have to activate the Control Toolbox.
1. Click on View, Toolbars, Control Toolbox.
2. You can integrate the Control Toolbox if you want by simply dragging it into your menu.
Create a Command Button
1. Click on Command Button from the Control Toolbox.
2. Now you can drag a command button on your worksheet.
Create and Assign the Macro
Now it is time to create a macro and assign it to the command button.
1. Right click on CommandButton1.
2. Click on View Code.
3. The Visual Basic Editor appears. Place you cursor between 'Private Sub CommandButton1_Click()' and 'End Sub'.
4. Add the line:
Range("A1").Value = "Hello"
5. Close the Visual Basic Editor.
6. Before you click on the command button, make sure Design Mode (most left field of the Control Toolbox) is deselected. You can do this by clicking on Design Mode again.
7. Click on CommandButton1.
Result:
Well done! You've just created a macro in Excel VBA!
Did you find this information helpful? Show your appreciation,follow me.
No comments:
Post a Comment