{"id":12104,"date":"2011-12-16T14:35:00","date_gmt":"2011-12-16T14:35:00","guid":{"rendered":"http:\/\/www.learnexcelmacro.com\/?p=1001"},"modified":"2011-12-16T14:35:00","modified_gmt":"2011-12-16T14:35:00","slug":"auto-open-macro-auto-run-macro","status":"publish","type":"post","link":"https:\/\/vmlogger.com\/excel\/2011\/12\/auto-open-macro-auto-run-macro\/","title":{"rendered":"Auto Open Macro \/ Auto Run Macro"},"content":{"rendered":"
Sometimes in Excel Macro, you need to execute a Macro \/ Piece of code as soon as you open the Workbook. By Doing this no need to trigger that Macro or functions just by opening that workbook. There are two methods to achieve this.<\/p>\n
Follow the below steps:
\n1.<\/strong>Open Visual Basic Editor (Alt + F11)
\n2.<\/strong>Add a Module in your VBA Project
\n3.<\/strong>In that Module Paste your Code inside Sub auto_open <\/strong><\/p>\n\nSub auto_open()\nMsgBox (\"Welcome \" & Application.UserName)\nEnd Sub\n<\/code><\/pre>\n