Previous post is better, put the code in the specific sheet's module, that
way if the user changes the sheet name, it will not cause the code to fail.
Bill
"cscorp" wrote in
message ...
Dear Sir,
Try this:
Place the code below in "ThisWorkbook" Module of your workbook
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
Dim SheetName As String
SheetName = "Sheet1"
If Sh.Name = SheetName Then
'Your code goes here
MsgBox "You Selected Sheet: " & Sh.Name
End If
End Sub
What you need to do:
Replace SheetName with the name of the sheet you want to capture and
place you code where it says "Your Code Here". Remenber to remove the
msgbox instruction I placed for ilustration.
What it does:
When you select Sheet1 (Name I selected for SheetName) will display a
message with the name of the selected sheet.
How it works:
When you select a sheet the "Workbook_SheetActivate" event fires.
Excel passes the sheet name through the variable "Sh".
SheetName = "Sheet1" -- Here you replace "Sheet1" with the name of
the sheet you want to capture.
If Sh.Name = SheetName Then
'PLACE YOUR CODE HERE
End If
Please, let me know if that solve your ploblem.
regards.
Juan Carlos
--
cscorp
------------------------------------------------------------------------
cscorp's Profile:
http://www.excelforum.com/member.php...o&userid=24015
View this thread: http://www.excelforum.com/showthread...hreadid=376995