REAL-TIME

VBA Projects

Full Access with Source Code
  • Designed and Developed by PNRao

  • Full Access with VBA Source Code

  • Well Commented Codes Lines

  • Creative and Professional Design

Effortlessly
Manage Your Projects

120+ Project Management Templates

Seamlessly manage your projects with our powerful & multi-purpose templates for project management.

120+ PM Templates Includes:
  • 50+ Excel Templates

  • 50+ PowerPoint Templates

  • 25+ Word Templates

Share Post
What is an Object and How to Understand it:

Understanding the Excel VBA Object Model is important to deal with different Excel Objects. Objects are similar to the objects in real world. If you consider House is an object, it have several characteristics.

Excel VBA Object Model – A Real world scenario
An House can have the following characteristics:

Objects: Several Small Objects like Room, Door, Wall, Fan,etc…
Properties: Different Measurements or Properties like Width, Height, Wall Colors, Names etc…
Collections: You can say all of the rooms as Rooms Collection, all the doors can be Doors Collection,etc…
Events: On Close the door, On Open the Door, On Switch on the TV,etc…
Methods: There will be different actions like Cleaning, Painting, Washing, Watching, etc…

Excel VBA Object Model

Similarly we have the same type of characteristics for Excel Objects. You can observe the following Worksheet characteristics.

A Worksheet can have the following characteristics:

Objects: Range,Cell,Shape, etc…
Properties: Sheet Name, Sheet Color, etc…
Collections: Ranges, Cells, Shapes,etc…
Events: On Sheet Activate, On Selection Change, etc…
Methods: Select, Activate, Copy, Paste,etc…

How to refer an Object:

UnderstandingObjects
Consider the following real life examples:

Example 1: If you want to switch off the Fan in the Dinning Room, you will go to Dining Room and find the appropriate switch and put off that. If you want to do the same thing with VBA, you will do some thing like this:

House.DinningRoom.Fan.Switch=Off

Example 2: If you want to close the Main Door, you will write something like this:
House.MainDoor.Close=True

Similarly, if you want to change the name of the Sheet2, your code will be:

Workbooks(“Wrokbook1”).Sheets(“Sheet2″).Name=”Data Sheet”

If you use Sheets(“Sheet2″).Name=”Data Sheet”, it will change the Sheet2 Name of the Active Workbook. If you want to change the Sheet2 Name of the Workbook1 you need to add Workbooks(“Wrokbook1”).

What are the Frequently Used Excel Object, Methods, Collections and Events:

Following are list of Object, Methods, Collections and Events which we commonly refer while automating Excel Jobs:

Objects Example Remarks
Workbook We can get the path of the Workbook using Workbooks(“Workbook1.xlsx”).Path Here Workbook1 is Workbook name
Sheet We can activate a worksheet using Sheets(“Sheet3”).Path Here Sheet3 is WorkSheet name
Range We can Enter a Value in a Range using
Range(“C2”).Value=3000
Here C2 is Range name
Cells We can Enter a Value in a same Range using
Cells(2,3).Value=3000
Here 2=Row number and 3=Column Number  of the Range C2

 

Properties Methods Collections Events
Value Select Workbooks Worksheet_Activate
Hidden Activate Worksheets Worksheet_Change
RowHeight Copy Cells Worksheet_SelectionChange
ColumnWidth Cut Shapes Workbook_Open
Interior.ColorIndex Paste ChartObjects Workbook_SheetChange
Font.ColorIndex Print Names Workbook_BeforeSave
Hidden Save Hyperlinks Workbook_BeforeClose
Merge Close AddIns Workbook_BeforePrint

Refer the following tutorial for more on this topic:

VBA Advanced Tutorials: Objects, Properties and Methods

Effortlessly Manage Your Projects and Resources
120+ Professional Project Management Templates!

A Powerful & Multi-purpose Templates for project management. Now seamlessly manage your projects, tasks, meetings, presentations, teams, customers, stakeholders and time. This page describes all the amazing new features and options that come with our premium templates.

Save Up to 85% LIMITED TIME OFFER
Project Management Templates

All-in-One Pack
120+ Project Management Templates

Essential Pack
50+ PM Templates

Excel Pack
50+ Excel PM Templates

PowerPoint Pack
50+ Excel PM Templates

MS Word Pack
25+ Word PM Templates

Ultimate Project
Management Template
Ultimate Resource
Management Template
Project Portfolio
Management Templates
Categories: Excel VBATags: , Last Updated: June 17, 2022

2 Comments

  1. Varun February 22, 2019 at 3:11 PM

    Somewhere you wrote Workbboks instead of Workbooks on this Page.

    https://analysistabs.com/excel-vba/object-model/#respond

  2. PNRao July 4, 2019 at 6:51 PM

    Thanks! updated!

Leave A Comment