Automatic Macros

D

Diego

Hey! I need some help form the pros, I need to create a
macro that runs automatically when the workbook in excel
opens, How do I do that? Thanks
 
S

Stef C

Use the Workbook_Open event of your workbook.

ex:
In your workbook VBA module

Private Sub Workbook_Open()

msgbox "Workbook Open!!!!!"

end sub
 
C

Chip Pearson

Diego,

You can name the macro Auto_Open. Alternatively, you can use the Open event
of the workbook. In the ThisWorkbook code module, use

Private Sub Workbook_Open()
' your code here
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com (e-mail address removed)
 
D

Diego

Thanks!!!! I tried naming it auto_open it worked. By the
way...How do I get to the this workbook code module? I
couldn't do it. Regards.
 
C

Chip Pearson

Diego,

You get to the ThisWorkbook module by first displaying the Project Explorer
window (View menu, Project Explorer, or just CTRL+R). Find your project in
the TreeView on the left side of the screen, and expand the folder. You'll
see a folder called "Microsoft Excel Objects". Expand that, and double click
the ThisWorkbook icon.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com (e-mail address removed)
 

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