Remarks

There's no singular Area object; individual members of the Areas collection are 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.

Example

Use the Areas property to return the Areas collection. The following example clears the current selection if it contains more than one area.

Visual Basic for Applications
If Selection.Areas.Count <> 1 Then Selection.Clear

Use Areas(), where is the area index number, to return a single Rangeobject from 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.

Visual Basic for Applications
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 the same time; 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.

Visual Basic for Applications
Set rangeToUse = Selection If rangeToUse.Areas.Count = 1 Then myOperation rangeToUse Else For Each singleArea in rangeToUse.Areas myOperation singleArea Next End If
Areas Collection Areas Collection Object

See also:

index index