Jeff
Jeff

Reputation: 1213

What are the events that I can use in Excel

Where can I find a list of events in Excel? I want to write macros in VBA based on them. I already know of Worksheet_BeforeDoubleClick, but I more or less just discovered that randomly/remembered it was used in Access.

Does anyone have a complete list or know where I can find one of the different events in Excel?

Upvotes: 7

Views: 228

Answers (3)

Todd Main
Todd Main

Reputation: 29153

These are some good links to learn about Excel's events:

  1. Beginning VBA: Events
  2. Event Macros, Worksheet Events and Workbook Events
  3. Events in Excel VBA

Upvotes: 3

Dick Kusleika
Dick Kusleika

Reputation: 33145

Another way to find them is open the VBE (Alt+F11), click on the object's class module (such as ThisWorkbook or Sheet1), and use the drop down boxes at the top of the code panel. If, for instance, you select ThisWorkbook from left drop down, the right drop down will contain all of the events available to you.

For objects that aren't Workbook or Worksheet (Application, QueryTable, etc), create a custom class module in your project (Insert - Class Module) and type (for example)

Public WithEvents qt As QueryTable

Now 'qt' will appear in the left drop down and all of the events for a QueryTable will appear in the right one. You'll notice that the Intellisense only shows a limited number of objects when you include WithEvents. These are the only objects that have exposed events. So you can't type

Public WithEvents rng As Range

because the Range object doesn't expose any events. A little more cumbersome than James' answer, but a nice way to browse the events when you know the object and to get a list of objects with exposed events.

Upvotes: 3

James Santiago
James Santiago

Reputation: 3062

Here is the excel object model overview which you can use to navigate to the members of each model.

http://msdn.microsoft.com/en-us/library/wss56bz7(VS.80).aspx

You would use this to get to:

http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.application_members.aspx

Scroll down for events.

Upvotes: 5

Related Questions