#1
|
|||
|
|||
How to Control Worksheet Event Handler in Module?
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range) End Sub Any help is appreciated. |
#2
|
||||
|
||||
As you've already observed, the Worksheet_SelectionChange code has to be run at the sheet level. Depending on your objective, you may be able to use the Workbook_SheetChange event, which runs from the 'ThisWorkbook' module and applies to all sheets.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
||||
|
||||
How to Control Worksheet Event Handler in Module?
You could create a class Module to wrap the worksheet.
By way of a very basic example... In a Class Module called clWsEvents Code:
Dim WithEvents Ws as Worksheet Private Sub Ws_SelectionChange(ByVal Target As Range) 'Do stuff End Sub Code:
Dim gWs as clWsEvents Sub Main() Set gWs = New clWsEvents Set gWs.Ws = ActiveWorkbook.Sheets('sheetName') 'Do other stuff End Sub |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Inserting a Word Module into excel | SarahBear | Excel Programming | 12 | 06-11-2014 05:26 AM |
How to summarise different worksheet to a summary worksheet | samkiewhock | Excel | 1 | 09-06-2012 03:34 AM |
AZWizard Module - ?hidden module | pcaldwell | Word | 1 | 08-22-2012 01:19 PM |
"Auto-populating" data-worksheet to worksheet. | meggenm | Excel | 4 | 02-04-2012 02:04 AM |
Outlook 2002 crashing - faulting module msmapi32.dll | Ken Cuvelier | Outlook | 3 | 12-12-2005 03:55 PM |