18.11.2014 Views

Microsoft Office

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Introducing Visual Basic<br />

for Applications<br />

This chapter is an introduction to the Visual Basic for Applications (VBA)<br />

macro language — a key component for users who want to customize<br />

Excel. This chapter teaches you how to record macros and create simple<br />

macro procedures. Subsequent chapters expand upon the topics in this chapter.<br />

Introducing VBA Macros<br />

In its broadest sense, a macro is a sequence of instructions that automates some<br />

aspect of Excel so that you can work more efficiently and with fewer errors. You<br />

may create a macro, for example, to format and print your month-end sales<br />

report. After the macro is developed, you can then execute the macro to perform<br />

many time-consuming procedures automatically.<br />

You need not be a power user to create and use simple VBA macros. Casual users<br />

can simply turn on Excel’s macro recorder: Excel records your actions and converts<br />

them into a VBA macro. When you execute this macro, Excel performs the<br />

actions again. More advanced users, though, can write code that tells Excel to<br />

perform tasks that can’t be recorded. For example, you can write procedures that<br />

display custom dialog boxes, add new commands to Excel’s menus, or process<br />

data in a series of workbooks.<br />

IN THIS CHAPTER<br />

Introducing VBA macros<br />

Creating VBA macros<br />

Recording VBA macros<br />

More about recording VBA<br />

macros<br />

Writing VBA code<br />

Learning more about VBA<br />

Displaying the Developer tab<br />

If you plan to work with VBA macros, you’ll want to make sure that the<br />

Developer tab is present in Excel. To display this tab:<br />

1. Choose <strong>Office</strong> ➪ Excel Options.<br />

2. In the Excel Options dialog box, select Personalize.<br />

3. Place a check mark next to Show Developer tab in the Ribbon.<br />

4. Click OK to return to Excel.<br />

681

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!