Selected and Deselected Event Handlers

You can use the Selected and Deselected events of a NamedRange to perform actions when text within the NamedRange is selected, and again when it is deselected. For example, suppose you want to show a control on the actions pane whenever text in a particular named range has focus and then hide the control when focus is moved away. For this, you can use the code in Listing 7.26.

Listing 7.26. Changing the actions pane when text in a NamedRange is selected and deselected

Dim calendar As New MonthCalendar

Private Sub NamedRange1_Selected(ByVal Target As _ Microsoft.Office.Interop.Excel.Range) Handles _ NamedRange1.Selected


End Sub

Private Sub NamedRange1_Deselected(ByVal Target As _ Microsoft.Office.Interop.Excel.Range) Handles _ NamedRange1.Deselected


Was this article helpful?

0 0

Post a comment