Tuesday, September 25, 2012

Excel VBA - Create a Macro in Excel 2003


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.

Activate the Control Toolbox in Excel 2003

2. You can integrate the Control Toolbox if you want by simply dragging it into your menu.

Integrate the Control Toolbox


Create a Command Button


1. Click on Command Button from the Control Toolbox.

Click on Command Button

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.

Right Click and then 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"

The Visual Basic Editor in Excel 2003

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:
First Macro 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