Wauvel

Excel like a finance pro.

← The library

VBA · Getting started

Modules, sheet modules, and class modules

Standard modules hold macros; sheet and ThisWorkbook modules hold events; class modules define objects.

CommonDifficulty 1200 · Proficient
Practice · 2 questions →

When to use it

Standard modules hold macros and functions. Sheet modules and ThisWorkbook hold event code for that object. Class modules define your own objects with properties and methods.

The code

Code
Insert > Module   Insert > Class Module

Worked examples

  • Standard module

    Insert > Module A standard module for Subs and Functions

    Where most code goes.

  • Sheet module

    Double-click Sheet1 in the Project Explorer The sheet module, for Worksheet_Change and friends

    Events only.

  • Class module

    Insert > Class Module, name it Customer A class with Public Name and a Method

    Set c = New Customer.

Worth knowing

  • Name modules by purpose: modImport, modReport.
  • Public procedures in a sheet module are called as Sheet1.ProcName.
  • Right-click a module, Export File, to back up code.

Where it goes wrong

  • Macros written in a sheet module do not show in the Macros dialog.
  • Class modules need New to instantiate.

Related

Learn the moves here — or let Wauvel run them on your numbers.

Meet your AI CFO →

One CFO-grade Excel tip a week

A short, practical email for finance operators — functions, shortcuts, and the moves that save an afternoon. Free, unsubscribe anytime.