VBA Getting Started: Setup and First Macro

VBA (Visual Basic for Applications) is Office's built-in scripting language for automating repetitive tasks.

1. Enable Developer Tab

File → Options → Customize Ribbon → check "Developer". The Developer tab now appears.

2. Open the VBA Editor

Press Alt+F11 to open the VBE (Visual Basic Editor).

3. Your First Macro

Insert → Module, paste:

Sub Hello()
    MsgBox "Hello, VBA!"
End Sub

Back in Excel, press Alt+F8 and run Hello.

4. Sub vs Function

  • Sub: performs an action, no return value
  • Function: computes and returns a value, callable from cells

Common Issues

  • Macros disabled? Save as .xlsm and enable macros in Trust Center
  • Project not visible? VBE → Tools → Options → check the relevant boxes

Tools

Want to convert your VBA to Python for data analysis? Try the online converter.