Figure Events for the Worksheet object

«

Böokl - Sheell (Code)

Ü

a

Worksheet _wj

S eI SCti nnCH anjjb w

3

Ftivata sub wotksliee'

"ijUJ

Aelivats

Bsfo rs Doublée h ck Ejeici ■ G K ic Iii CI ck Ca it j a;e Charge Daactivate

End Sub

elaclionChsnae

For instance, if we choose the SelectionChange event, Excel will automatically produce the following code shell:

Private Sub Worksheet SelectionChange(ByVal Target As Excel.Range) End Sub

Excel will even place the cursor between the two code lines so we can begin entering event code.

As the name implies, this event fires when the current selection is changed in the worksheet. Note that Excel will fill in the Target parameter with the Range object that represents the new selection. Thus, our event code has access to the new selection, but not to the previous selection. Many events have parameters associated with them. This provides a way for Excel to pass us information related to the event.

The same approach will work for the workbook and chart events, but Application events require a different approach, which we will discuss later in the chapter.

The Excel events are listed in Table 11-1 through Table 11-5.

0 0

Post a comment