Datasheet
15
Chapter 1: What Is VBA?
In the following sections, I briefly describe some common uses for VBA
macros. One or two of these may push your button.
Inserting a bunch of text
If you often need to enter your company name, address, and phone number
in your worksheets, you can create a macro to do the typing for you. You
can extend this concept as far as you like. For example, you might develop
a macro that automatically types a list of all salespeople who work for your
company.
Automating a task you perform frequently
Assume you’re a sales manager and you need to prepare a month-end sales
report to keep your boss happy. If the task is straightforward, you can
develop a VBA program to do it for you. Your boss will be impressed by the
consistently high quality of your reports, and you’ll be promoted to a new job
for which you are highly unqualified.
Automating repetitive operations
If you need to perform the same action on, say, 12 different Excel workbooks,
you can record a macro while you perform the task on the first workbook and
then let the macro repeat your action on the other workbooks. The nice thing
about this is that Excel never complains about being bored. Excel’s macro
recorder is similar to recording live action on a video recorder. But it doesn’t
require a camera, and the battery never needs to be recharged.
Creating a custom command
Do you often issue the same sequence of Excel menu commands? If so, save
yourself a few seconds by developing a macro that combines these com-
mands into a single custom command, which you can execute with a single
keystroke or button click. You probably won’t save that much time, but you’ll
probably be more accurate. And the guy in the next cubicle will be really
impressed.
05_503690-ch01.indd 1505_503690-ch01.indd 15 4/12/10 11:22 PM4/12/10 11:22 PM