SheetActivate/DeActivate events in a common module
Your workbook event code works fine for me, try this too
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
Dim sCodeName As String
sCodeName = Sh.CodeName
Select Case sCodeName
Case "Sheet1"
MsgBox "Sheet1", , "Case Sheet1"
Case Else
MsgBox sCodeName, , "Case Else"
End Select
End Sub
Bear in mind you might not be able to return codenames of newly insterted
sheets until the wb has been saved or without further intervention.
Regards,
Peter T
"Dileep Chandran" wrote in message
oups.com...
Hi Nick,
Thanks for your time. But it doesnt seems to work. Here is the code I
put in ThisWorkbook module:
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
If Sh.CodeName = "Sheet1" Then
MsgBox("Test1")
Else
If Sh.CodeName = "Sheet2" Then
MsgBox("Test2")
End if
End if
End Sub
Any idea what went wrong?
-DC
|