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

Collection in Excel VBA helps to loop through the group of items:

Collections in Excel VBA
In This Section:

Introduction to Collections in Excel VBA?

Collection is an object contains group of objects having similar characteristics (with same properties and methods). For example,if you want to loop through all worksheets in a workbook, you can refer worksheets collection of the workbook and do whatever you want to do with that particular worksheet.

Collections in Excel VBA

Introduction to Collections in Excel VBABelow are the most frequently used Collections in the Excel VBA:

Collections Use
AddIns Collection We can loop through the installed and available add-in in your Excel. You can use it for finding all available add-ins
ChartObjects Collection We can loop through the all the charts in a Worksheet or workbook. You can use it for performing some thing with all or some of the available Charts in the Workbook or Worksheet
Charts Collection It is similar to the above collection
Comments Collection We can loop through the all comments in the workbook and we can change any properties of all or some comments
HPageBreaks Collection We can loop through the Horizontal page breaks and change the settings
Hyperlinks Collection We can loop through the all hyperlinks in the workbook and change the properties
Names Collection We can loop through All names and change the properties
OLEObjects Collection We can loop through all ActiveX controls and change the properties
PivotCaches Collection We can loop through the all pivot caches in the workbook and change the properties
PivotTables Collection We can loop through all the pivot tables and change the formats and other properties
Range Collection We can loop through all ranges
Shapes Collection We can loop through shapes including chart in workbook and change the properties
Sheets Collection We can loop through all sheets in the workbbok
Windows Collection We can loop through all windows
Workbooks Collection We can loop through available or opened workbook and access their data or change its properties
Worksheets Collection We can loop through all worksheets in the workbook and change its properties

Examples Macro File On Collections

Example 1: This code will loop through the Worksheets in a Workbook and display the names of the worksheets
Private Sub CommandButton1_Click()
Dim sh
For Each sh In ThisWorkbook.Worksheets
    MsgBox sh.Name
Next
End Sub
Example 2: This code will loop through the Chart objects in a Worksheet and display the names of the Chart Objects
Private Sub CommandButton2_Click()
Dim cht
For Each cht In ActiveSheet.ChartObjects
    MsgBox cht.Name
Next
End Sub

Download File:

ANALYSIS TABS – Collections

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. Sunil BS July 19, 2017 at 9:39 PM

    Hi ,
    Thanks for sharing your knowledge and helping many people like me.

    I am a novice in this.

    I would like to know more about Objects in VBA; when to use them and how to invoke them. Could you please help

    Thanks,

Leave A Comment