Hello everyone! Did you know …I’m now going to show you how to set up your first Microsoft Excel Vba Macro.
book a session
First things first for your first Microsoft Excel Vba Macro
The first thing to do is to switch on the Developer Tab on the Ribbon. By default it is switched off. You do this in the Backstage area –
File / Options / Customize Ribbon / tick on “Developer” on “Main Tabs” right hand side of the screen
You will now see the new Developer tab on the Ribbon.
Turning on the recorder
You can now set up Microsoft Excel Vba Macros! Start by clicking on the strange looking button on the bottom Status bar, left hand corner of the screen just beside the “Ready” status. This is called the Macro recorder indicator. Click on it once. Click OK to record your macro.
First don’t do anything!
Do not do anything just yet because every action you now take in Microsoft Excel will be recorded in the Vba Macro you are now in.
Your name, please
Just click on cell C5 to select it. Key in your name and press return.
Stop!
Now click the Macro recorder indicator to stop the recording.
Let’s see the code
Press on ALT + F8 and click Edit. You will see Sub at the start with its Macro Name, (), a comment indicated by ‘ and End Sub at the end, with some code in between which reads:
Range(“C5”).Select
ActiveCell.FormulaR1C1 = “whatever your name is, I am: Martin Loughman”
Range(“C6”).Select
Back to normality
Go back to the spreadsheet by pressing ALT + F11. Delete your name.
Run!
Then do ALT + F8 again but this time click Run. Your name appears again and you can keep on going through this process forever!
In praise of you
Well done – you have just recorded and ran your first Microsoft Excel Vba macro and it will be saved in your spreadsheet when you save your spreadsheet!
Additional Info
Special Save As is required
When you have a macro in your file, it’s required that you save the file as file type:
Excel Macro-Enabled Workbook
Making the macro active
It’s also important to click “Enable Content” on the alert at the top of the screen which might appear when you open a file which has a macro. Only click this if you trust and know the source of the macro.