An Excel VBA reference can mean either Microsoft’s documentation for Excel’s VBA object model or a library that a VBA project needs in order to recognize particular objects and commands. To browse Excel’s objects, open the Visual Basic Editor and press F2; to manage a project’s library references, choose Tools > References in that editor.
What “Excel VBA reference” means
The phrase is used in two related ways. The Excel VBA reference is documentation describing the objects, properties, methods, events, constants, and functions that VBA code can use to work with Excel. A VBA project reference is a setting that connects a workbook’s code to a type library, such as the Excel object library or a library supplied by another application.
For example, the Excel object model includes the Workbook, Worksheet, and Range objects. A workbook contains worksheets, and a worksheet contains cells represented by ranges. Code such as Worksheets("Sales").Range("A1").Value follows that object hierarchy: it identifies the Sales worksheet, then cell A1, then its value. The reference documentation explains which members are available and what arguments they accept.
These meanings are connected but not interchangeable. Reading a reference page helps you understand how an object works; checking a library in the References dialog tells the VBA editor which definitions are available to a project. Most ordinary Excel macros can use Excel’s built-in object model without adding another reference.
Where to find the reference documentation
For Microsoft 365 on Windows, open Excel’s Visual Basic Editor with Alt+F11. If the Developer tab is not visible, enable it through File > Options > Customize Ribbon and select Developer. In the editor, press F2 to open the Object Browser. Use its library or project selector to choose Excel, then search for a term such as Range, Worksheet, or Workbooks.
The Object Browser is an in-editor index, not a full tutorial. Select a class or member to inspect its available members and, where shown, its description. It is useful when you know a name but need to check spelling, discover related members, or confirm whether something is a property, method, or event. The Microsoft Learn Excel object model reference provides browsable online documentation and is often easier to read alongside an example.
On Mac, open the Visual Basic Editor from Developer > Visual Basic; keyboard shortcuts can depend on the keyboard and function-key settings. The editor’s menus and available documentation features can differ from Windows, so use the editor’s Tools menu to locate References if needed. Excel for the web does not create or run VBA macros; use the desktop application for VBA work.
How Excel’s object model is organized
Excel VBA works through objects arranged in relationships. At the top are application-level objects, including Application and collections such as Workbooks. A workbook exposes worksheets and other workbook features; a worksheet exposes ranges, charts, and many other elements. A member is something an object provides: a property returns or sets information, a method performs an action, and an event signals that something happened.
- Object:
Worksheets("Summary")identifies a worksheet object. - Property:
Range("A1").Valueaccesses the value held in a cell. - Method:
Range("A1").ClearContentsperforms an action on a range. - Collection:
Workbooksrepresents a group of open workbooks, whileWorksheetsrepresents a workbook’s worksheets.
Understanding the hierarchy makes reference pages much more useful. If a page documents a property of a Range, that property applies to a range object, not automatically to every Excel object. The Object Browser can help you identify the owning class; online reference pages then explain the member’s behavior and parameters. This distinction also helps diagnose errors caused by calling a valid member on the wrong type of object.
How to manage library references
In the Visual Basic Editor, choose Tools > References to see the libraries available to the current VBA project. A checked item is available to that project. Excel’s own object library and the standard VBA libraries are normally enabled in an Excel workbook, so do not change them unless you have a specific reason. A reference can be useful when code uses types or constants defined by another library, such as an automation library or a database component.
When a reference is checked, VBA can use its definitions while compiling the project. This is called early binding when code declares a variable with a specific library type. For instance, code can declare an object as a particular class supplied by a referenced library, which enables features such as editor-assisted member lists and compile-time checking. The trade-off is that another computer may not have the same library installed or may have a different compatible version.
Late binding declares an external object more generally and creates or obtains it at runtime. It can reduce reliance on a checked reference, but it also removes some editor assistance and moves certain errors until the code runs. It is not automatically better: use the approach that suits the project’s deployment needs, and verify the target computers and applications. Neither approach removes the need to check that the relevant software or component is actually available.
Read a small example through the reference
The example below uses only Excel’s built-in object model. It lists the worksheet names in the workbook that contains the macro. Before running any macro, save a copy of the workbook: macros cannot be undone with Ctrl+Z, even though this particular example only displays a message.
Option Explicit
Sub ShowWorksheetNames()
Dim wb As Workbook
Dim ws As Worksheet
Dim names As String
' Use the workbook that stores this macro.
Set wb = ThisWorkbook
' Add each worksheet name to the message.
For Each ws In wb.Worksheets
names = names & vbCrLf & ws.Name
Next ws
MsgBox names, vbInformation, "Worksheets"
End Sub
Here, ThisWorkbook is a workbook object, Worksheets is its worksheet collection, and ws.Name reads a worksheet property. The loop uses a worksheet variable to refer to each member of that collection. Looking up each term in the Object Browser or the online reference helps explain why the code works and how to adapt it. For example, ThisWorkbook means the workbook containing the code; it is not necessarily the workbook currently selected on screen.
To inspect the code in the editor, use Insert > Module if the project does not already have a standard module, then paste the procedure. In Excel, macros may require a macro-enabled workbook format such as .xlsm. Only enable macros from sources you trust, and follow your organization’s security settings.
Common reference problems and fixes
A common error appears when a project depends on a library that is not available at its saved location or on the current computer. In Tools > References, the unavailable entry is commonly marked with MISSING:. Code that depends on its types or constants may then fail to compile, sometimes with a message such as “Can’t find project or library.” The macro may have worked on the original computer because that machine had the needed component installed.
- Open Tools > References and identify the missing library rather than checking or unchecking items at random.
- If the project legitimately needs that component, install or restore a compatible version using an approved source, then reopen the project and check the reference.
- If the reference is no longer needed, remove it only after reviewing the code for types, constants, or calls that depend on it.
- Compile the project through Debug > Compile VBAProject, if that command is available, to find remaining compile-time problems.
Other errors are not missing-reference errors. A misspelled member, a variable declared with the wrong type, or a member used on the wrong object can cause a compile error even when all libraries are present. If a name appears valid in the documentation but does not work in your code, check the object that owns it, the spelling, the arguments, and whether the code’s object variable has been set.
Version, platform, and safety considerations
The core Excel object model is longstanding, but not every feature behaves identically across Excel versions, operating systems, or installation configurations. A workbook that automates another Office application or relies on an additional component is more likely to encounter compatibility issues than a macro using basic worksheet and range operations. Test important VBA projects in the Excel versions and environments where they will actually be used.
VBA is available in the desktop Excel applications, including Microsoft 365 for Windows and Mac, but the editor, integrations, and some automation capabilities are not identical across those platforms. Excel for the web can open many macro-enabled files, but it cannot run or edit VBA macros. A workbook’s VBA project also does not automatically travel with every file format: saving as a macro-free workbook can remove its VBA code. Keep a separate backup before changing formats or references.
Macros can change data, files, and application settings, and Ctrl+Z does not reverse their actions. Review code before running it, especially if it came from an email, download, or unfamiliar workbook. Enable macros only when you trust the source and understand the purpose. For workbooks containing important information, use a copy or a controlled test file while learning.
When to use another source or approach
Use the Object Browser when you are already writing code and want quick access to available classes or members. Use Microsoft Learn when you need fuller descriptions, syntax details, examples, or documentation that can be searched outside the editor. A VBA language reference explains general language features, while the Excel object model reference focuses on Excel-specific objects. For example, documentation about loops and data types answers a different question from documentation about a worksheet’s properties.
If your goal is to automate Excel without VBA, consider whether a built-in feature or Office Scripts fits the task. Office Scripts are a separate automation option for supported Microsoft 365 environments and are not VBA; they use a different language and execution model. Excel formulas, Power Query, or recorded actions may also be more appropriate for repeatable data transformations. Choose based on where the workbook will run, who needs to maintain it, and whether the task requires VBA’s desktop automation capabilities.
Frequently Asked Questions
Where is the Excel VBA Object Browser? In the desktop Visual Basic Editor, press F2 to open it. Select the Excel library or project in its selector and search for an object or member.
How do I open the VBA References window? Open the Visual Basic Editor, then choose Tools > References. Select a library only when the project needs it; an unavailable dependency may appear with a MISSING label.
Do I need to add an Excel reference for every macro? No. A VBA project in Excel normally has access to Excel’s built-in object model. Additional references are needed only when code depends on types or members from another library.
Why does my VBA project say “Can’t find project or library”? One possible cause is a missing or incompatible checked library reference. Inspect Tools > References first, then check for other compile errors if no missing entry explains the problem.
Can I use VBA in Excel for the web? No. Excel for the web does not run or edit VBA macros. Open the workbook in desktop Excel to work with its VBA project.
Related
- Excel Next Sheet Shortcut for Windows, Mac and Web
- Excel Shortcut Keyboard Mat: What It Is and How to Choose
- Excel Shortcut Mouse Pad: What to Look For
Try it: the Column Letter to Number: aA is 27, XFD is 16,384. Converts both ways.
More in VBA & macros
- Excel VBA: List All Sheets in a WorkbookTo list every sheet in the workbook that contains your VBA code, loop through its Sheets collection and…
- Excel VBA Copy and Paste a Row: Practical Code GuideTo copy a row with Excel VBA, specify the source and destination worksheet rows and use Copy Destination.…
- VBA Array Length: Count Elements and Find BoundsIn VBA, calculate an array’s length as UBound(array) - LBound(array) + 1. The expression works for a one-dimensional…
- Excel VBA Get Username: Windows or Excel User Name?In Excel VBA on Windows, use Environ$("USERNAME") to read the current Windows account name. Use Application.UserName instead if…
- How to Create a Word Template With MacrosTo create a Word template that contains a macro, start with a blank document or an existing file,…
- VBA Range Variables: How to Declare and Use ThemA VBA Range variable is an object variable that refers to one or more cells in an Excel…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.