Objects are created from the class. If we take some real-life examples then let’s say a Dog is a class where it has its properties and methods like breed, age, and color whereas we can say Dog1 or Dog2 are objects having different breeds, ages, and colors. We can simply say the object is a grouping of data and functions. In VBA “Collection” is a class where we can create its object using “New” so that we can use its in-built methods like Add, Remove and Count.
Object Components
Properties
It is used to read or write a value where we can read the value from the object or we can write a value to the object but we can’t update the value in the object
Methods
Some actions are performed by this method in the object collection is an object where we can perform many actions with the help of methods like Add, Count, and Remove. The following code is shown to add a value in the collection object using the “Add” method
Events
When an event occurs a function executes called events in the object. Events are like clicking a button, opening a workbook, or activating a worksheet. The following code is shown to display a message by “MsgBox” after an event Workbook_Open() takes place
Creating a VBA Object
To create an object we have to follow three steps
- A variable should be declared
- A new object should be created
- The new object should be assigned to the variable
These three steps can be done in many ways which are discussed in the following,
Using Dim with New
In a single line, we can declare, create and assign the object. We can’t use the declare variable to create multiple objects. In the following code, we are creating an object of Collection and storing it in a variable “Collection_12”.
Using Set with New
We are declaring the variable to store the object using Dim in one line than in another line we can create and assign the object.
Using Let
It is used to assign a value to the variable of an inbuilt object like String, Long, Integer, or Double. Let is used to store the value whereas set is used to store the address. In the following code, a variable is assigned by a value and that variable is a data type of string which is also an inbuilt object.
When New is Not Required
When we want to create an object of a workbook or worksheet at that time we usually don’t use New without using New we can create an object.
In VBA there are four important objects,
- Application Object
- Workbook Object
- Worksheet Object
- Range Object
- Shape Object
Application Object
The entire Excel Application is referred to as Application Objects. The application object contains the workbook object which we can use to manipulate the data present in the application object. The following code is to change the color of the font to red in the application.
Workbook Object
All worksheets which are currently open in excel are referred to as workbook objects. We can use the workbook object to add a sheet to the workbook or to save the existing sheets in the workbook.
Worksheet Object
It refers to the present sheet of excel which is in the active state, we can use it to manipulate the active sheet. In the following code, we will change the orientation of the active sheet to the landscape.
Range Object
It is used to refer to a group of cells or a single cell so that we can manipulate it according to our desire. In the following code, we are selecting a range of cells from A1 to C6.
Shape Object
It is used to add a shape or to change the dimension of the active sheet. In the following code, a rounded rectangle shape is added in the active sheet where the value of the rounded portion of the rectangle will be 100 and 200 in the top right and left part whereas the value of the bottom right and left will be 50.

Similar Reads
Application Objects in Excel VBA
The Excel VBA Application object is one of the most commonly utilized objects when using VBA to automate any task. It uses several Excel programs and runs various operations on Excel Workbooks. To work with the Excel Application Object, it has many Properties and Methods. Below is a brief descriptio
2 min read
Basic Object Model in Excel VBA
VBA stands for visual basic for application. Excel VBA is an object-based programming language, it is used while recording a macro i.e., it uses the idea of Encapsulation and stores the state (data) and operation (functions) inside the object. Excel objects are arranged in a hierarchy that governs t
3 min read
VBA Strings in Excel
In Excel's Visual Basic for Applications(VBA), strings are pivotal in handling and manipulating text-based data. Strings serve as a fundamental data type used to store a sequence of characters, enabling the representation of textual information, numbers, symbols, and more. Understanding how VBA hand
8 min read
Sub Procedure in Excel VBA
A Sub Procedure is an action that is written in VBA code. It starts with a Sub statement and ends with an End Sub statement. It is used to manipulate the data in an Excel sheet which includes a table present in an Excel sheet or a pivot table present in the Excel sheet. The name of the procedure sho
3 min read
Worksheets in Excel
If you're new to MS Excel, you've likely heard the term "worksheet." But have you ever wondered what an Excel worksheet actually is? So, in a spreadsheet program, a worksheet is a collection of cells (it is a basic data unit in the worksheet) where you can store and manipulate data. By default, ever
5 min read
Power View in Excel
In today's data-driven world, the ability to turn raw data into meaningful insights is a skill that can unlock countless opportunities. Enter Power View, a remarkable data visualization technology that empowers users to transform their data into interactive and engaging charts, graphs, maps, and mor
8 min read
VBA Find Function in Excel
In an Excel sheet subset of cells represents the VBA Range which can be single cells or multiple cells. The find function will help to modify our search within its Range object. A specific value in the given range of cells is to search with the help of the Find function. Excel VBA provides different
5 min read
Excel VBA | sum() functions
Visual Basic for Applications (VBA) is the programming language of Excel and other offices. It is an event-driven programming language from Microsoft. With Excel VBA one can automate many tasks in excel and all other office software. It helps in generating reports, preparing various charts, graphs a
2 min read
VBA Arrays in Excel
Arrays are used to store data of similar data types. Suppose there are 300 students rather than declaring 300 variables for students, we can declare one array where we can store 300 elements. In this article, we will learn about excel VBA arrays. Declaration of Array Declaring an array is similar to
5 min read
Workbook and Worksheet Object in Excel VBA
Excel VBA is an object-oriented programming language, which means in excel every component is an object. The superset of all the objects of excel is the excel application itself. The Excel Application Object is the root of all the other objects in excel. It contains Workbook Object. The Workbook Obj
4 min read