Range Property (Shapes Collection)

         Example         Applies To

Returns a ShapeRange object that represents a subset of the shapes in a Shapes collection.

Syntax

expression.Range(Index)

expression   Required. An expression that returns a Shapes object.

Index   Required Variant. The individual shapes to be included in the range. Can be an integer that specifies the index number of the shape, a string that specifies the name of the shape, or an array that contains either integers or strings.

Remarks

Although you can use the Range property to return any number of shapes, it's simpler to use the Item method if you only want to return a single member of the collection. For example, Shapes(1) is simpler than Shapes.Range(1).

To specify an array of integers or strings for Index, you can use the Array function. For example, the following instruction returns two shapes specified by name.

Dim arShapes() As Variant
Dim objRange As Object
arShapes = Array("Oval 4", "Rectangle 5")
Set objRange = ActiveSheet.Shapes.Range(arShapes)

In Microsoft Excel, you cannot use this property to return a ShapeRange object containing all the Shape objects on a worksheet. Instead, use the following code:

Worksheets(1).Shapes.Select        ' select all shapes
set sr = Selection.ShapeRange    ' create ShapeRange