0% found this document useful (0 votes)
71 views4 pages

Chapter 1.1 - Create A Macro

Chapter 1.1 - Create a Macro

Uploaded by

putra.stat11
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
71 views4 pages

Chapter 1.1 - Create A Macro

Chapter 1.1 - Create a Macro

Uploaded by

putra.stat11
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Excel Easy

#1 Excel tutorial on the net Excel Introduction Basics Functions Data Analysis VBA 300 Examples Ask us

Create a Macro Search Entire Site Go

Developer Tab | Command Button | Assign a Macro | Visual Basic Editor


Chapter < >
With Excel VBA you can automate tasks in Excel by writing so called macros. In this chapter, learn how to create
a simple macro which will be executed after clicking on a command button. First, turn on the Developer tab. Create a Macro

Developer Tab
To turn on the Developter tab, execute the following steps.
Learn more, it's easy
1. Right click anywhere on the ribbon, and then click Customize the Ribbon.
Swap Values

Run Code from a Module

Macro Recorder

Use Relative References

FormulaR1C1

Add a Macro to the Toolbar

Macro Security

Protect Macro

2. Under Customize the Ribbon, on the right side of the dialog box, select Main tabs (if necessary). Download Excel File
3. Check the Developer check box.
create­a­macro.xls

Follow Excel Easy

4. Click OK.

5. You can find the Developer tab next to the View tab.
Command Button
To place a command button on your worksheet, execute the following steps.

1. On the Developer tab, click Insert.

2. In the ActiveX Controls group, click Command Button.

3. Drag a command button on your worksheet.

Assign a Macro
To assign a macro (one or more code lines) to the command button, execute the following steps.

1. Right click CommandButton1 (make sure Design Mode is selected).

2. Click View Code.

The Visual Basic Editor appears.

3. Place your cursor between Private Sub CommandButton1_Click() and End Sub.

4. Add the code line shown below.


Note: the window on the left with the names Sheet1, Sheet2 and Sheet3 is called the Project Explorer. If the
Project Explorer is not visible, click View, Project Explorer. To add the Code window for the first sheet, click
Sheet1 (Sheet1).

5. Close the Visual Basic Editor.

6. Click the command button on the sheet (make sure Design Mode is deselected).

Result:

Congratulations. You've just created a macro in Excel!

Visual Basic Editor


To open the Visual Basic Editor, on the Developer tab, click Visual Basic.

The Visual Basic Editor appears.


1/9 Completed! Learn much more about creating macros >
Back to Top: Create a Macro | Go to Next Chapter: MsgBox

EXCEL EASY • FREE EXCEL HELP • COPYRIGHT (C) 2010­2017 • ALL RIGHTS RESERVED
MICROSOFT EXCEL TUTORIAL | HOW TO USE VBA | EXCEL FORMULAS | DROP­DOWN LIST

You might also like