0
votes

Using a Personal workbook with macros, how do I make it so a macro runs as soon as you open any workbook? I've found not-quite-solutions to this (code is below), but it doesn't do what I need because it only works when you open Excel for the first time. I want to be able to keep Excel open, and any new workbooks that are opened will trigger a macro to run.

Sub workbook_open() 
MsgBox ("Hello.")
End Sub
1
You can use a button to let the user select the workbook which the user want's to open. This will be way better than running code on opening ANY workbook (if that's even possible).nvkrj

1 Answers

0
votes

You want to use the Workbook Open event. Please this in a workbook module:

Private Sub Workbook_Open() 
 Msgbox("Hello.")
 ' Whatever other code you like here too.
End Sub