Thread: Autoexec Macro
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.excel.worksheet.functions
Peo Sjoblom Peo Sjoblom is offline
external usenet poster
 
Posts: 3,268
Default Autoexec Macro

2 ways, either put the macro in ThisWorkbook like

Private Sub Workbook_Open()

'your code here

End Sub

or name i Auto_Open

Sub auto_open()'your code here
End Sub

I personally use the former, to get there right click the excel icon next to
File menu and select view code
or press alt + F11 and double click ThisWorkbook in the project pane to the
left, then close with
alt + Q

-
Regards,

Peo Sjoblom

(No private emails please)


"Rick" wrote in message
...
How can I make a procedure (or macro) run every time a workbook is opened?

I've tried naming it
Private Sub Autoexec()
and
Private Sub Startup()

But neither work. I'm sure I've done this before but I just can't
remember
how.
I looked for startup options (like in Access) but I can't find where to
name
a startup macro.

I don't want to use a switch on the startup line.

If anyone can help I'd really appreciate it.

Thanks,
Rick