Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run a Macro on opening a file

Status
Not open for further replies.

NellyC

Technical User
Jan 31, 2005
13
GB
Can anyone help, I have an excel file which has a formula generated list on one of the sheets. I want to record a macro to resort the list (This is not a problem) but i don't know how to set the macro to run automatically when the file is opened.

Any advice would be greatly appreciated.

Thanks

NellyC
 
Hi,

Right click the Sheet Tab and select View Code. This displays the VB Editor.

If the Project Explorer is not displayed in the VB Editor, View/Project Explorer.

In the Project Explorer are displayed the Excel Objects. One of them is ThisWorkbook. Select ThisWorkbook.

In the Code Window, select the Object DropDown (upper left) and select Workbook from the list.

In the Code Window, select the Procedures DropDown (upper right) and select Open from the list.

In the Workbook_Open event code, type your macro name.
Code:
Private Sub Workbook_Open()
  MyMacro
End Sub



Skip,

[glasses] [red]Be advised:[/red] Researchers have found another Descartes trueism, "Cogito ergo spud."
"I think; therefore, I YAM!
[tongue]
 
Thanks Skip that worked a treat

NellyC
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top