How do you do the following using VBA macro automatically?

L

LunaMoon

Hi all,

I would like to have the following run every time when the Excel 2003
sheet is opened:

so I am going to put the VBA macro into AUTO_RUN function...

Now when the Excel 2003 file is opened,

I need the following:

1. refresh/recalculate all the sheets in the Excel 2003 file;
2. save all the sheets;
3. close out the file.

Please help me translate these into VBA/MACRO... thanks a lot!
 
G

Gord Dibben

Excel has no AUTO_RUN function.

Did you mean Auto_Open?

I would put this code into Thisworkbook Module.

Private Sub Workbook_Open()
Application.Calculate
With ThisWorkbook
.Save
.Close
End With
End Sub

But note...............you will have to disable events if you ever want to
keep the workbook open for editing.


Gord Dibben MS Excel MVP
 

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