The primary Excel objects are the Workbook, the Worksheet, the Range and the Cell


There are many other objects in Excel.

When programming Excel with VBA, each object you are working with should be assigned to a variable.

Unlike a recorded macro that refers to "Active" and "Selected" objects, VBA code is often written without opening and selecting Excel objects until the program runs.

VBA programs can be very complex and can have several workbooks, worksheets and other Excel objects open.

It is necessary to use variables for any objects that will be refered to in your code.

There are many objects in Excel

These are the most common.

Not used very much in an Excel VBA program. It is mostly used when working with Excel from another application, such as Access or Word.

This is an Excel file - .xls#. It can be an existing one or a new one.

A specific worksheet in a workbook - new or existing.

A group of cells, or a single cell, in a worksheet. These can be named and referenced.

An individual cell, like A1. Cells can contain values, formulas, formatting, etc.

Methods and Properties

Methods are things that an object can do.

Properties are attributes and characteristics of objects.

Here is an example with a car - formatted like we would in Excel VBA.

A car is an object and it has certain characteristics, or properties

Each of these properties will have a value that matches the specific car.

Methods are things a car can do.

We use a Method in our code to make an object do something.

Copyright © 2006-2016, LQSystems,Inc. All rights reserved.

   Printer Friendly Page