Referring to Rows and Columns [Excel 2003 VBA Language 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.
||All the rows on the worksheet|
||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() Worksheets("Sheet1").Activate Dim myUnion As Range Set myUnion = Union(Rows(1), Rows(3), Rows(5)) myUnion.Font.Bold = True End Sub