Run a Macro on Startup for Specific Spreadsheet

R

Rod

Does any one know how I can setup a specific worksheet to run a macro only
when that specific worksheet is opened? Note: I do not want this macro to
run for any other worksheet, just this specific one.

Thanks
 
T

Trevor Shuttleworth

Rod

I think you are looking for:

Private Sub Worksheet_Activate() in the specific worksheet class (code)
module.

For "open" read "activate".

Regards

Trevor
 
R

Rod

Trevor, you Excel skills are greater than mine. Can you copy paste a
specific example assuming I had a macro named "autoexec"?

Thanks,

Rod
 
D

Don Guillett

right click the sheet tab>view code>left window select worksheet>right
window select activate>insert your macro to run>SAVE
 
G

Gord Dibben

Rod

Private Sub Worksheet_Activate()
autoexec
End Sub

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

Copy/paste the above to that module.

Note: autoexec must be available in the workbook, otherwise you have to point
to it.

Private Sub Worksheet_Activate()
Application.Run ("mymacros.xla!autoexec")
End Sub


Gord Dibben 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

Top