Sep 21 2020 12:41 PM
Trying to complete an open event code: to automatically run another macro when opening Excel.
Does anyone know the code for this?
Sep 21 2020 02:20 PM - edited Sep 21 2020 02:23 PM
So you said when Excel opens. To do that you must first learn how to run a macro when a workbook opens. So let us tackle that first
There are 3 options to 'auto run' a macro when a workbook opens:
For this discussion we will use the ThisWorkbook Workbook_Open event.
Under your workbook click ThisWorkbook in Project Explorer. Then select Workbook in code window then select Open in dropdown. Add code to Workbook_Open() sub which can be the code you want to run or a call to another routine to run
So now you have code that will run when this workbook opens. To make it run every time Excel opens we have 2 options:
For this discussion I recommend option 2. Here are resources to explain it in more detail:
https://analysistabs.com/excel-vba/run-macro-automatically-opening-workbook/