Auto Run Excel VBA Macro Code when opening workbook


The below works only if you have allowed macros to run in excel. Obviously when you have disabled macro’s, it doesnt work 🙂

Let’s say you have a macro called ‘update’ that you want to run every time someone opens the workbook.
You put the following code in the ‘ThisWorkbook’ object in vba:

Private Sub Workbook_Open()

'Define the macro you wish to run
Run update

End Sub

The macro itself (in this case “update”) must be the name of the procedure in any standard public module (Insert>Module).