How to: Refer to Rows and Columns

Excel Developer Reference

Use the Rows property or the Columns property to work with entire rows or columns. These properties return a Range object that represents a range of cells. In the following example, Rows(1) returns row one on Sheet1. The Bold property of the Font object for the range is then set to True.

  Sub RowBold()
    Worksheets("Sheet1").Rows(1).Font.Bold = True
End Sub

The following table illustrates some row and column references using the Rows and Columns properties.

Reference Meaning
Rows(1) Row one
Rows All the rows on the worksheet
Columns(1) Column one
Columns("A") Column one
Columns All the columns on the worksheet

To work with several rows or columns at the same time, create an object variable and use the Union method, combining multiple calls to the Rows or Columns property. The following example changes the format of rows one, three, and five on worksheet one in the active workbook to bold.

  Sub SeveralRows()
    Dim myUnion As Range
    Set myUnion = Union(Rows(1), Rows(3), Rows(5))
    myUnion.Font.Bold = True
End Sub

See Also