Rows (collection)

<< Click to Display Table of Contents >>

Rows (collection)

Access paths for the rows of a worksheet:

Application à Workbooks à Item à Sheets à Item à Rows

Application à Workbooks à Item à ActiveSheet à Rows

Application à ActiveWorkbook à ActiveSheet à Rows

Application à ActiveSheet à Rows

Application à Rows

Access paths for the rows of arbitrary ranges:

Application à Workbooks à Item à Sheets à Item à Range à Rows

Application à Workbooks à ActiveSheet à Range à Rows

Application à ActiveWorkbook à ActiveSheet à Range à Rows

Application à ActiveSheet à Range à Rows

Application à Range à Rows

Access paths for the rows of entire table columns:

Application à Workbooks à Item à Sheets à Item à Columns à Item à Rows

Application à Workbooks à ActiveSheet à Columns à Item à Rows

Application à ActiveWorkbook à ActiveSheet à Columns à Item à Rows

Application à ActiveSheet à Columns à Item à Rows

Application à Columns à Item à Rows

Access paths for the rows in the currently selected cells:

Application à Workbooks à Item à Sheets à Item à Selection à Rows

Application à Workbooks à ActiveSheet à Selection à Rows

Application à ActiveWorkbook à ActiveSheet à Selection à Rows

Application à ActiveSheet à Selection à Rows

Application à Selection à Rows

 1  Description

Rows is a collection of all rows in a worksheet or range. The individual elements of this collection are of the type Range, which allows you to apply all properties and methods available for Range objects to them.

 2  Access to the object

Rows can be a child object of two different objects:

As a child object of a Sheet object, it represents all rows of this worksheet.

As a child object of a Range object, it represents all rows of this range.

Examples for Rows as a child object of a Sheet object:

' Display the number of rows in the current worksheet

MsgBox pm.ActiveSheet.Rows.Count

 

' Format the first row in the worksheet in boldface

pm.ActiveSheet.Rows(1).Font.Bold = True

Examples for Rows as a child object of a Range object:

' Display the number of rows in the specified range

MsgBox pm.ActiveSheet.Range("A1:F50").Rows.Count

 

' Format the first row in a range in boldface

pm.ActiveSheet.Range("A1:F50").Rows(1).Font.Bold = True

 3  Properties, objects, collections and methods

Properties:

Count R/O

 

Objects:

Item Range (default object)

Application Application

Parent Sheet or Range

Count (property, R/O)

Data type: Long

Returns the number of Range objects in the Rows collection – in other words: the number of the rows in the worksheet or range.

Item (pointer to object)

Data type: Object

Returns an individual Range object, i.e. a range that contains one individual row.

Which Range object you get depends on the numeric value that you pass to Item: 1 for the first row, 2 for the second, etc.

Example:

' Set the font for the second row of the worksheet to Courier New

pm.ActiveSheet.Rows.Item(2).Font.Name = "Courier New"

Application (pointer to object)

Returns the Application object.

Parent (pointer to object)

Returns the parent object, i.e. an object that is either of the type Sheet or Range .