Skip to Content
Excel VBA Programming For Dummies, 6th Edition
book

Excel VBA Programming For Dummies, 6th Edition

by Dick Kusleika
February 2022
Beginner to intermediate content levelBeginner to intermediate
432 pages
9h 21m
English
For Dummies
Content preview from Excel VBA Programming For Dummies, 6th Edition

Chapter 11

Automatic Procedures and Events

IN THIS CHAPTER

Bullet Knowing the event types that can trigger an execution

Bullet Finding out where to place your event-handler VBA code

Bullet Executing a macro when a workbook is opened or closed

Bullet Executing a macro when a workbook or worksheet is activated

You have a number of ways to execute a VBA Sub procedure. One way is to arrange for the Sub to be executed automatically. In this chapter, you explore the ins and outs of this potentially useful feature, learning how to set things up so that a macro is executed automatically when a particular event occurs.

Preparing for the Big Event

An event is basically something that happens in Excel. Following are a few examples of the types of events that Excel can recognize:

  • A workbook is opened or closed.
  • A window is activated or deactivated.
  • A worksheet is activated or deactivated.
  • Data in a cell is entered or changed.
  • A workbook is saved.
  • An object, such as a button, is clicked.
  • A particular key or key combination is pressed.
  • A particular time of day occurs.
  • An error occurs.

Dozens of different types of events ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Excel VBA Programming For Dummies, 5th Edition

Excel VBA Programming For Dummies, 5th Edition

Michael Alexander, John Walkenbach

Publisher Resources

ISBN: 9781119843078Purchase Link