Visual Basic for Applications/Editing Macros

< Visual Basic for Applications

This lesson introduces editing macros.

Objectives and Skills

Objectives and skills for editing macros include:

Readings

  1. Read Microsoft: Create or Delete a Macro.
  2. Read Excel-Easy: Create a Macro.
  3. Read Microsoft: Run a Macro.
  4. Read Microsoft: MsgBox Function.
  5. Read Home & Learn: The Excel Visual Basic for Applications Development Environment.

Multimedia

  1. Watch YouTube: Excel VBA MsgBox Tutorial.

Examples

'This macro displays a message in a message box.

Sub ShowMessage()
    MsgBox "VBA is fun!"
End Sub

Activities

  1. Display content in a message box.
    1. Using Excel, create a new macro that uses MsgBox to display "Hello <your name>!". Insert your name in the macro.
    2. Experiment with running your macro using <F5>, using the Macros dialog box, and assigning a shortcut key.
  2. Run a macro.
    1. Run your Hello macro using a button on the Quick Access toolbar.
    2. Run your Hello macro using a button in a custom tab or custom group on the Ribbon.
    3. Run your Hello macro using a graphic object area.
  3. Run a macro automatically.
    1. Configure your Hello macro to run automatically whenever the workbook is opened Auto_Open.
    2. Test your macro to ensure that it runs automatically.
    3. Test holding down the Shift key to prevent your macro from running automatically.
  4. Research VBA malware.
    1. Review SC Magazine: VBA Malware on the Rise.
    2. Consider how easy it is to create malware using VBA.
    3. Research and consider ways to protect yourself from VBA malware.

See Also

References

    This article is issued from Wikiversity - version of the Thursday, December 03, 2015. The text is available under the Creative Commons Attribution/Share Alike but additional terms may apply for the media files.