Visual Basic for Applications/Editing Macros
Appearance
This lesson introduces editing macros.
Objectives and Skills
[edit | edit source]Objectives and skills for editing macros include:
- Setting procedure options by using the Macro Options dialog box
- Modifying the Visual Basic development environment
Readings
[edit | edit source]- Microsoft: Create or Delete a Macro
- Excel-Easy: Create a Macro
- Microsoft: Run a Macro
- Microsoft: MsgBox Function
- Home & Learn: The Excel Visual Basic for Applications Development Environment
Multimedia
[edit | edit source]Examples
[edit | edit source]'This macro displays a message in a message box.
Sub ShowMessage()
MsgBox "VBA is fun!"
End Sub
Activities
[edit | edit source]- Display content in a message box.
- Using Excel, create a new macro that uses MsgBox to display "Hello <your name>!". Insert your name in the macro.
- Experiment with running your macro using <F5>, using the Macros dialog box, and assigning a shortcut key.
- Run a macro.
- Run your Hello macro using a button on the Quick Access toolbar.
- Run your Hello macro using a button in a custom tab or custom group on the Ribbon.
- Run your Hello macro using a graphic object area.
- Run a macro automatically.
- Configure your Hello macro to run automatically whenever the workbook is opened Auto_Open.
- Test your macro to ensure that it runs automatically.
- Test holding down the Shift key to prevent your macro from running automatically.
- Research VBA malware.
- Review SC Magazine: VBA Malware on the Rise.
- Consider how easy it is to create malware using VBA.
- Research and consider ways to protect yourself from VBA malware.