|
Use the Excel Rows property or the Excel Columns property to work with entire rows or columns in Microsoft Excel. These properties return a Range object that represents a range of Excel cells. In the following example, Rows(1) returns row one on Excel Sheet1. The Bold property of the Font object for the Excel range is then set to True. Sub MakeRowBold() Worksheets("Sheet1").Rows(1).Font.Bold = True End Sub |
| The following table illustrates some row and column references using the Rows and Columns properties in Microsoft Excel. |
|
Reference Rows(1) Rows Columns(1) Columns("A") Columns |
Meaning Row one All the rows on the Excel worksheet Column one Column one All the columns on the Excel worksheet |
|
To work with several rows or columns at the same time in Excel, 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 Excel worksheet one in the active Excel 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 The following training video shows how to create a macro to make the first row bold in an Excel spreadsheet. |
![]()
Custom Search
|