How to autostart a macro?

D

Delivery

Can a macro be self-starting based on some event?

Events such as:
1) opening the file
2) preset time
3) value of certain cell contents

Trying to set a spreadsheet to run a series of queries and macros every
night.

Also hope to learn if i can set up a series of queries and macros to run in
sequence whether autostart or not.

Could these macros run even if the Excel file is not open?
 
D

Dave Peterson

#1. You can use a sub named: Auto_Open (placed in a General module)
or you can use the Workbook_Open event in the ThisWorkbook module.

#2. You can use application.ontime to start a macro when you want.
Chip Pearson shows how:
http://www.cpearson.com/excel/OnTime.aspx

#3. If the value changes because of the user typing something, you can use the
worksheet_change. If the value changes because of a formula recalculating, you
can use the worksheet_calculate event.

If you're new to macros:

Debra Dalgleish has some notes how to implement macros here:
http://www.contextures.com/xlvba01.html

David McRitchie has an intro to macros:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Ron de Bruin's intro to macros:
http://www.rondebruin.nl/code.htm

(General, Regular and Standard modules all describe the same thing.)

Chip Pearson has some instructions on events:
http://www.cpearson.com/excel/events.htm

David McRitchie has some notes, too:
http://www.mvps.org/dmcritchie/excel/event.htm

There are application events, too.
You can read more about application events at Chip Pearson's site:
http://www.cpearson.com/excel/AppEvent.aspx
 

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