Run macro automatically.

E

Excel macro

How do I make a macro run automatically when a worksheet it is attached to is
loaded?
 
D

Don Guillett

right click on the sheet tab>view code>left window worksheet>right window
activate
 
S

Sheela

I am unable to find "activate " when I right click on worksheet. ( i assume
that you are referring to the windows explorer kind of interface which opens
up on the left of the visula basic window) . Sorry! I am new to excel and
many thanks for your quick response.
 
R

Ron de Bruin

Hi

See Chip Pearson's site for more info
http://www.cpearson.com/excel/events.htm

Example code :

Sub Auto_open()
MsgBox "Hi"
End Sub

Must be in a normal module
If you use a Auto_open macro then this wil not run if you open the file with a macro

Or a event

Private Sub Workbook_Open()
'macro name or code
End Sub

Right click on the Excel icon next to File in the menubar
And choose View code

You are now in the Thisworkbook module
Paste the Event in this place
Alt-Q to go back to Excel
Save and close the file
 
D

Don Guillett

You said worksheet. To us that means each tab within the workbook which is
the file....
 
S

Sheela

Thanks a bunch...It works. Also how do I make the macro run automatically
whenever the value in a cell changes?
 

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