Page 146 - Excel Progamming Weekend Crash Course
P. 146
h540629 ch10.qxd 9/2/03 9:34 AM Page 121
SESSION
10
Using Ranges and Selections
Session Checklist
✔ Using the Range object
✔ Understanding relative ranges
✔ Worksheet comments
✔ Using columns and rows to determine range location and size
✔ Naming ranges
any of the actions carried out by a VBA program target a specific part of a work-
sheet. Clearly, you need a way to identify parts of a worksheet, from a single cell to
Mthe entire worksheet. VBA uses the Range object as well as its cousin the Selection
object for this purpose.
The Range Object
The Range object is designed to refer to a group of cells in a worksheet. This can be a single
cell, or it can be a rectangular block of cells of any size up to the limits of the worksheet
itself. When you want to perform some action in a worksheet, such as applying formatting
or entering data, you almost always start by obtaining a Range object that refers to the cells
upon which to be acted.
The most common way to obtain a Range reference is from the Worksheet object’s Range
property:
wsRef.Range(ref)