Using the Areas Collection to Return a Noncontiguous Range

The Areas Collection is a collection on non-contiguous ranges within a selection. It consists of individual Range objects representing contiguous ranges of cells within the selection. If the selection contains only one area, the Areas collection contains a single Range object corresponding to that selection.

Refer to Figure 3.12. You need to copy only the total numbers (the gray cells) and paste them to a new section. You might be tempted to loop through the sheet, copy a row, and paste it to another section. But there's an easier way (see Figure 3.13):

Figure 3.12

You want to copy the gray cells to another area.

0 0

Post a comment