Automatic Startup for a Macro

  • Thread starter Thread starter Guest
  • Start date Start date
Private Sub Workbook_Open()

your code or macro name here

End Sub

To access the Thisworkbook module, right-click on the Excel logo just left of
"File" on menu.

Select "View Code".

In dialog box drop-down at top left select Workbook and the Private Sub
Workbook_Open().........End Sub will be inserted.

Copy your macro code between the Open() and End Sub lines.

Or just enter the macro name, assuming the macro is in the same workbook.

If not in the same workbook, perhaps in Personal.xls or an Add-in, go to
Tools>References and checkmark the reference to use.

Save/Close and reopen.


Gord Dibben Excel MVP
 
dlw

In Excel in a General Module you would name it Auto_Open

In the Thisworkbook Module it would be Workbook_Open


Gord Dibben Excel MVP
 
I have code I place in In Excel in a General Module with name Auto_Open.
When I hold the shift key down, it still runs. Is there a way to turn off
with VBA code?
 
You sure the code runs?

Holding down Shift Key should prevent the code from running but will not
prevent the "this workbook contains macros" message.

Test with this in a new saved workbook.

Sub auto_open()
MsgBox "hello"
End Sub


Gord
 
Back
Top