Forum Discussion
aekbus
Oct 18, 2024Brass Contributor
Run macro on startup
I have written a macro I ant to run when the spreadsheet it is in is launched. I have followed the instructions exactly in Help, yet the macro does not run.
Has anyone experienced this issue and is there a workaround or fix for it?
- I thought lthat may have been the problem, but I didn't test it. Thanks.
4 Replies
Sort By
Please help us help you by telling us which steps you took.
- aekbusBrass ContributorI clicked on the ThisWorkbook module in the VBA Project Explorere folder and the following appeared:
Private Sub Workbook_Open()
' Put your code here
End Sub
I named my macro "Startup()" and placed it where it told me to put it (of course, stripping off the Sub and End Sub lines from my macro) and renaming "Workbook_Open()" with "Startup()".
It did not run at startup. The named variables are all defined as "Public" in Module 1. The following is the first several lines of my code:
Private Sub Startup()
' This subroutine runs automatically at startup
' It determines whether or not "Create Next Month" and "Delete This Month"
' buttons are displayed.
Application.ScreenUpdating = False 'Turn off screen
MyDate = Date 'parse today's date
etc.
End Sub
Hope this helps.Thanks! You should not have renamed Workbook_Open to Startup. Change
Private Sub Startup()
back to
Private Sub Workbook_Open()
Save and close the workbook, then reopen it. The code should now run.