Start a macro when click on tab sheet

  • Thread starter Thread starter Nancy
  • Start date Start date
N

Nancy

Hi,



When I click on a tabsheet to open a sheet I would like that automaticly
u=one macro start to update this sheet.
It is possible?
Thank you in advance

Nancy
 
Paste this into the worksheet module
Private Sub Worksheet_Activate()
MsgBox "start to update this sheet"
End Sub
 
Paste this into the worksheet module
Private Sub Worksheet_Activate()
MsgBox "start to update this sheet"
End Sub

I try it but nothing happens!

Nancy
 
put the code on the sheet that is activated when you click the tab,
for example, if you want the code to fire when you click on sheet2
then in the vb editor, double click sheet2 under ms excel objects and paste his
code there.

Private Sub Worksheet_Activate()
MsgBox "start to update this sheet"
End Sub
 
Jean

Where did you place the code?

Right-click on the sheet tab and "View Code"

Copy/paste the code into that sheet module.

Switch to another sheet then back to first sheet to "Activate" the code.


Gord Dibben MS Excel MVP
 

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

Back
Top