I want to run a macro every time an excel files opens and before it closes. I've tried using the below script but it didn't work.
Private Sub Worksheet_Activate()
'my macro
End Sub
Opens:
Private Sub Workbook_Open()
' dosomething
End Sub
or
Sub Auto_Open()
in a moduleCloses:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
' dosomething
End Sub
or
Sub Auto_Close()
in a moduleSources:
MsgBox("Hello World!")
but nothing appears when I open the workbook