Description
A collection of the areas, or contiguous blocks of cells, within a selection. There is no singular Area object; individual members of the Areas collection are Range objects. The Areas collection contains one Range object for each discrete, contiguous range of cells within the selection. If the selection contains only one area, the Areas collection contains a single Range object that corresponds to that selection.
Accessors
Use the Areas method without an argument to return the entire collection. The following example clears the current selection if the selection contains more than one area.
If Selection.Areas.Count <> 1 Then Selection.Clear
Use the Areas method with an area index number as an argument to return a single area in the collection. The index numbers correspond to the order in which the areas were selected. The following example clears the first area in the current selection if the selection contains more than one area.
If Selection.Areas.Count <> 1 Then Selection.Areas(1).Clear End If
Some operations cannot be performed on more than one area in a selection at once; you must loop through the individual areas in the selection and perform the operations on each area separately. The following example performs the operation named "myOperation" on the selected range if the selection contains only one area; if the selection contains multiple areas, the example performs myOperation on each individual area in the selection.
Set rangeToUse = Selection If rangeToUse.Areas.Count = 1 Then myOperation rangeToUse Else For Each singleArea in rangeToUse.Areas myOperation singleArea Next End If
Properties
Application Property, Creator Property, Count Property, Parent Property.
Methods
Item Method.