Link to home
Start Free TrialLog in
Avatar of NewToVBA
NewToVBAFlag for United States of America

asked on

Worksheet_SelectionChange

Hello Experts - Is it possible to control any sheet in workbook off one module with code
Worksheet_SelectionChange(ByVal Target As Excel.Range)? As somebody here advised me earlier, rather than copying same macro to each sheet I could use this avenue instead.
For example, I want to do this when click on any cell in sheet1 through Sheet20  ...
Worksheet_SelectionChange(ByVal Target As Excel.Range)
msgbox activecell.value

Cheers, V
ASKER CERTIFIED SOLUTION
Avatar of Wayne Taylor (webtubbs)
Wayne Taylor (webtubbs)
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of NewToVBA

ASKER

Hi Wayne -  I am not able to "wake up" the code. I place it in Module1, and click on sheets with no effect. Must be doing something wrong...

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
MsgBox ActiveSheet.Name
End Sub

tks, V
Read Wayne's post again.

>> The code for this would go in the ThisWorkbook module.
Thank you, Wayne!
Hi Teylyn - thank you for your comment
cheers, v