Row related procedures in class Range (Excel VBA)

This page presents procedures from class Range related to the theme Row: CalculateRowMajorOrder, EntireRow, ListHeaderRows, Row, RowDifferences and Rows


Calculates a specified range of cells.

The CalculateRowMajorOrder method calculates the specified range cell-by-cell, from its top-left corner to its to bottom-right corner in row-major order. This is the same process that is used by Excel 2000 and earlier versions to calculate a range.



Returns a Range object that represents the entire row (or rows) that contains the specified range.

Dim rngEntireRow As Range
Set rngEntireRow = ActiveCell.EntireRow


Returns the number of header rows for the specified range.

Before you use this property, use the CurrentRegion property to find the boundaries of the range.

Dim lngListHeaderRows As Long
lngListHeaderRows = ActiveCell.ListHeaderRows


Returns the number of the first row of the first area in the range.

Dim lngRow As Long
lngRow = ActiveCell.Row


Returns a Range object that represents all the cells whose contents are different from those of the comparison cell in each row.

RowDifferences (Comparison)

Comparison: A single cell to compare with the specified range.

Dim rngRowDifferences As Range
Set rngRowDifferences = ActiveCell.RowDifferences(Comparison:=)


Returns a Range object that represents the rows in the specified range.

To return a single row, use the Item property or equivalently include an index in parentheses. For example, both Selection.Rows(1) and Selection.Rows.Item(1) return the first row of the selection. When applied to a Range object that is a multiple selection, this property returns rows from only the first area of the range. For example, if the Range object someRange has two areas—A1:B2 and C3:D4—,someRange.Rows.Count returns 2, not 4. To use this property on a range that may contain a multiple selection, test Areas.Count to determine whether the range is a multiple selection. If it is, loop over each area in the range, as shown in the third example. The returned range might be outside the specified range. For example, Range("A1:B2").Rows(5) returns cells A5:B5. For more information, see the Item property. Using the Rows property without an object qualifier is equivalent to using ActiveSheet.Rows. For more information, see the Worksheet.Rows property.

Dim rngRows As Range
Set rngRows = ActiveCell.Rows