Selecting Cells
There are a variety of tools for selecting cells in a workbook.
Contents
Columns
The Columns function is useful for simply selecting one or more columns. The intuitive name makes for a more readable program and should be preferred when possible.
Sub foo
Columns("A:C").Select
End SubColumns takes either the letter or index (counting from 1). Columns("C") and Columns(3) can be used interchangeably.
Rows
The Rows function is useful for selecting one or more rows.
Sub foo
Rows("1:3").Select
End Sub
Range
The Range function is useful for non-contiguous selections, such as Range("A:A,C:C").
Sub foo
Range("A:A").Select
End Sub
Given a selection
To expand a selection from a single cell or a range, consider one of the following:
Columns
To expand a cell or range into a column, use the EntireColumn property.
Sub foo
Range("C5").EntireColumn.Select
End Sub
Rows
To expand a cell or range into a row, use the EntireRow property.
Sub foo
Range("C5").EntireRow.Select
End Sub