Run Macro When Specific Sheet Selected

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Can someone tell me the code to run a macro when a specific sheet is first
selected? I need it to have a text box appear momentarily when the user
selects the sheet. Thanks in advance.
 
right click sheet tab>view code>left window select worksheet>right window
select activate.
 
Carl

You can use a Worksheet_Activate() event like so

Private Sub Worksheet_Activate()
MsgBox "You activated sheet " & Me.Name
End Sub

To implement just right click on the sheet tab and select View Code. Paste
in the resulting window and save. Now when you activate that sheet the
msgbox will pop up

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
(e-mail address removed)
web: www.nickhodge.co.uk

UK Excel User Conference In Cambridge
November 28th - December 1st 2007
Register Now @ http://www.exceluserconference.com/UKEUC.html
 
Thanks. Worked perfectly!

Nick Hodge said:
Carl

You can use a Worksheet_Activate() event like so

Private Sub Worksheet_Activate()
MsgBox "You activated sheet " & Me.Name
End Sub

To implement just right click on the sheet tab and select View Code. Paste
in the resulting window and save. Now when you activate that sheet the
msgbox will pop up

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
(e-mail address removed)
web: www.nickhodge.co.uk

UK Excel User Conference In Cambridge
November 28th - December 1st 2007
Register Now @ http://www.exceluserconference.com/UKEUC.html
 
Back
Top