This chapter shows you different ways of referring to ranges such as specifying a row or column. You also find out how to manipulate cells based on the active cell and how to create a new range from overlapping ranges.

Use theIntersectMethod to Create a New Range from Overlapping Ranges 72

Use theISEMPTYFunction to Check Whether a Cell Is Empty 73

Use theCurrentRegionProperty to Select a Data Range 73

Use theAreasCollection to Return a Noncontiguous Range 76

Referencing Tables 77

Next Steps 77

A range can be a cell, a row, a column, or a grouping of any of these. The RANGE object is probably the most frequently used object in Excel VBA—after all, you are manipulating data on a sheet. Although a range can refer to any grouping of cells on a sheet, it can refer to only one sheet at a time. If you want to refer to ranges on multiple sheets, you must refer to each sheet separately.

The Range Object

The following is the Excel object hierarchy:

Application > Workbook > Worksheet > Range

The Range object is a property of the Worksheet object. This means it requires that a sheet be active or it must reference a worksheet. Both of the following lines mean the same thing if Worksheets(1) is the active sheet:

Range("A1")
Worksheets(1).Range("A1")

There are several ways to refer to a Range object. Range("A1") is the most identifiable because that is how the macro recorder refers to it. However, each of the following is equivalent when referring to a range: