Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Setting Up the VBA Environment | Introduction to VBA and the Excel Object Model
Excel VBA for Business Automation

Setting Up the VBA Environment

Swipe to show menu

VBA's tools are hidden by default because most Excel users never need them. Before you write a line of code, you need to switch on the Developer tab, get comfortable with the Visual Basic Editor (VBE), and understand the one file-format rule that trips up almost every beginner.

Enabling the Developer Tab

  1. Go to File → Options;
  2. Click Customize Ribbon;
  3. In the right-hand list of main tabs, check the box next to Developer;
  4. Click OK. The Developer tab now appears in your ribbon.
carousel-imgcarousel-imgcarousel-img

Opening the Visual Basic Editor

Press Alt+F11 from anywhere in Excel (or click Visual Basic on the Developer tab). This opens the VBE — a separate application window where all VBA code lives. Three panels matter most while you're learning:

  • Project Explorer (top-left) — a tree view of every open workbook, its worksheets, and its code modules;
  • Properties window (bottom-left) — settings for whatever object is selected in the Project Explorer;
  • Code window (right) — where you read, write, and run VBA procedures.

Exploring the Project Explorer

In the image above, notice the hierarchy: VBAProject (Section_1_VBA_Intro.xlsm) contains Microsoft Excel Objects (one entry per worksheet, plus ThisWorkbook) and, once you add any code, a Modules folder. Standard code — the kind you'll write for most of this course — belongs in a Module, not directly behind a worksheet or ThisWorkbook. Right-click VBAProject → Insert → Module to add one.

Saving Macro-Enabled Workbooks (.xlsm)

Note
Note

If you save a workbook that contains VBA code as a normal Excel Workbook (.xlsx), Excel silently deletes every macro. There is no warning dialog you can miss — Excel does warn you, but it's easy to click through without reading it. Always choose Excel Macro-Enabled Workbook (*.xlsm) from the "Save as type" dropdown whenever a file contains code.

Task

Get your environment ready.

  1. Open Section_1_VBA_Intro.xlsx and enable the Developer tab if it isn't already visible.
  2. Press Alt+F11 and locate the Employees worksheet and ThisWorkbook in the Project Explorer.
  3. Insert a new Module (right-click the VBAProject → Insert → Module) and rename it in the Properties window to modIntro.
  4. Save the file as Section_1_VBA_Intro.xlsm using File → Save As → Excel Macro-Enabled Workbook.
Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 1. Chapter 2

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

Section 1. Chapter 2
some-alt