Run Macro When Specific Sheet Selected

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.
 
D

Don Guillett

right click sheet tab>view code>left window select worksheet>right window
select activate.
 
N

Nick Hodge

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
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top