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

120+ PROFESSIONAL

Project Management Templates

120+ PM Templates Includes:
  • 50+ Excel Templates

  • 50+ PowerPoint Templates

  • 25+ Word Templates

Effortlessly Manage Your Projects

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

Share Post

We have seen different Objects in the previous tutorial, we will see the different examples on Workbook, Sheets, Range and Cell objects in this session.
Objects in Excel VBA - Workbook, Sheets, Range and Cell

Workbook Object in Excel VBA

The following are some example codes on Workbook Object, will help you dealing with various methods and properties of Excel workbook.

How to activate a Workbook

Yo can use Activate method to activate a Workbook as shown below:

Workbooks(“Workbook1.xlsx”).Activate

How to get the path of the Workbook

Yo can use FullName method of a Workbook as shown below:

Workbooks(“Workbook1.xlsx”).Path

How to get the full path (including name) of the Workbook

Yo can use FullName method of a Workbook as shown below:

Workbooks(“Workbook1.xlsx”).FullName

How to change the name of the Workbook

Workbooks(“Workbook1″).Name=”New Name”

Worksheet Object of Workbook in Excel VBA

The following are some example codes on Worksheet Object, will help you to deal with activating and selecting Excel worksheet.

How to Activate a Worksheet

Sheets(“Sheet2”).Activate

How to Select a Worksheet

Sheets(“Sheet2”).Select

How to rename a Worksheet

Sheets(“Sheet2″).Name=”NewSheet”

How to Hide a Worksheet

Sheets(“Sheet2”)..Visible = False

How to UnHide a Worksheet

Sheets(“Sheet2”).Visible = True

Range Object of Worksheet in Excel VBA

The following are some example codes on Range Object, will help you to deal with range colors, selection, etc.

How to Select a Range

Range(“A3”).Select

How to Enter Some Data in a Range

Range(“A3”).value=3000

How to change background color of Range

Range(“A1:E20”).Interior.ColorIndex=5

How to Clear a Range

Range(“A1:E20”).Clear

How to Copy a Range from one sheet to another sheet

Sheets(“Sheet1”).Range(“A1:E20”).Copy Destination:=Sheets(“Sheet2”).Range(“D1”)

Cells Object of Worksheet in Excel VBA

The following are some example codes on Cells Object.

How to Select a Range(“A3”)

Cells(3,1).Select

How to Enter Some Data in a Range(“A3”)

Cells(3,1).value=3000

How to change Font color of a Cell

Cells(3,1).Font.ColorIndex=5

How to Clear all Cells of a worksheet

Sheets(“Sheet1”).Cells.Clear

How to Clear only content not formats of all Cells of a worksheet

Sheets(“Sheet1”).Cells.ClearContents

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

One Comment

  1. Reinaldo Rojas April 4, 2020 at 4:31 PM - Reply

    Excelente work

Leave A Comment