Create Excel macro screencast
Write a VBA macro
The below steps describe how to create a macro (also called Procedure or Sub). The next section shows steps how to run the macro. At the bottom there is a screencast showing it all.
|If you can't see the Developer tab on the ribbon, follow the procedure Add developer tab
- Open the Visual Basic Editor: on the Developer tab in group Code press the Visual Basic button.
- Insert a standard module. Standard modules give a more direct name in the Macro dialog.
Insert module In the Visual Basic Editor/ProjectExplorer pane place the cursor on ThisWorkbook. Go to the menu and select on tab Insert > Module.
- Declare the macro procedure and give it a name.
Sub MyFirstMacro ... End Sub
Declare the macro In the Visual Basic Editor go to the coding window, the right empty space next to the Project explorer pane and Type Sub MyFirstMacro...End Sub. Place the cursor in the sub and add the code, let's say
Sub MyFirstMacro() MsgBox("hello world") End Sub
- Add some code statements you want the macro to run, here we let display a simply message box
Run the VBA macro you have just written
There are several ways to start the VBA macro you have just written, for example:
- Go in the Excel sheet to the Macro Button on the Developer tab
- Press Run and select the macro to run it
The other way is
- In the Developer environment place your cursor in the just made macro
- Press F5
Click image to start. 10 secs to load video, 13 secs to explain, includes explanatory subtitles at the bottom.