Many of my future posts will include macros scripting (VBA) in Excel. Below is a quick tutorial on how to set up and incorporate Macros in your Excel Document.
- Open up Excel and save as .xlsm
Select File, Save As. For "Save as type:" change it to Excel Macro-Enabled Workbook (*.xlsm) - (I tend to do this first so I don't forget later)
In this example I saved it as "Fake Macro Doc.xlsm" - Check macro Trust Center Security Settings
Select File, Options, Trust Center, Trust Center Settings (Button).
Then in Macro Settings select "Disable all macros with notification" or if you are bold - "Enable all macros"
In Message bar select "Show the Message Bar in all applications when active content, such as ActiveX controls and macros, has been blocked. Then hit OK twice. - Pull up the VBA Editor window
Hit Alt+F11 or go to view, macros, edit. - Insert a new module
With the document selected in the left window (in this case "Fake Macro Doc.xlsm") go to the top bar and select Insert, Module. This should make the new module appear in the left window. Double click it and the white blank doc is where you paste your code.
Quick Video - Run your code
On the top toolbar right under debug is the play button. Have your cursor somewhere within the code and hit play.
And that's it! If this post was helpful leave a comment!
Thanks,
Jon
Jon
No comments:
Post a Comment