Startup Macro

aparna

New Member
Joined
Nov 4, 2005
Messages
16
How do I make a macro run automatically when a excel file is opened. What do I name this macro.
Aparna
 

Some videos you may like

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.

Oaktree

MrExcel MVP
Joined
Jun 20, 2002
Messages
7,988
In the ThisWorkbook module, put:

Code:
Private Sub Workbook_Open()
'rest of code in here
End Sub
 

al_b_cnu

Well-known Member
Joined
Jul 18, 2003
Messages
4,494
Hi,

Right-click any worksheet tab, select 'View Code', then select 'ThisWorkbook' from the list on the left and insert the following:
Code:
Private Sub Workbook_Open()
MsgBox "Hello"
End Sub
 

aparna

New Member
Joined
Nov 4, 2005
Messages
16
I tried using this code the way you indicated...but it didn't work.

Private Sub Workbook_Open()
Range("A1").Select
End Sub

Excel does't run this code during startup. Is there anything else that i need to do

Aparna
 

Oaktree

MrExcel MVP
Joined
Jun 20, 2002
Messages
7,988
Did you put it in the ThisWorkbook module and enable macros?
 

Watch MrExcel Video

Forum statistics

Threads
1,119,002
Messages
5,575,497
Members
412,670
Latest member
Khin Zaw Htwe
Top