Skip to Main Content
Microsoft Excel 365 Bible
book

Microsoft Excel 365 Bible

by Michael Alexander, Dick Kusleika
March 2022
Beginner to intermediate content levelBeginner to intermediate
1072 pages
28h 16m
English
Wiley
Content preview from Microsoft Excel 365 Bible

CHAPTER 43Working with Excel Events

In the preceding chapters, we presented a few examples of VBA event-handler procedures for ActiveX controls. These procedures are the keys to making your Excel applications interactive. This chapter introduces the concept of events for Excel objects and includes many examples that you can adapt to meet your own needs.

Understanding Events

Excel monitors a variety of events and can execute your VBA code when any of these events occur. This chapter covers the following types of events:

  • Workbook events  These occur for a particular workbook. Examples include Open (the workbook is opened or created), BeforeSave (the workbook is about to be saved), and NewSheet (a new sheet is added). You must store VBA code for workbook events in the ThisWorkbook code module.
  • Worksheet events  These occur for a particular worksheet. Examples include Change (a cell on the sheet is changed), SelectionChange (the selection on the worksheet is changed), and Calculate (the worksheet is recalculated). VBA code for worksheet events must be stored in the code module for the worksheet (for example, the module named Sheet1).
  • Special Application events  The final category consists of two useful application-level events: OnTime and OnKey. These are different from other events because the code isn't in a class module. Rather, you set the ...
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 2019 Bible

Excel 2019 Bible

Michael Alexander, Richard Kusleika, John Walkenbach

Publisher Resources

ISBN: 9781119835103Purchase Link