GroupShapes.Range Property
Excel Developer Reference |
Returns a ShapeRange object that represents a subset of the shapes in a Shapes collection.
Syntax
expression.Range(Index)
expression A variable that represents a GroupShapes object.
Parameters
Name | Required/Optional | Data Type | Description |
---|---|---|---|
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 is simpler to use the Item method if you want to return only a single member of the collection. For example, Shapes(1)
is simpler than Shapes.Range(1)
.
Example
This example sets the fill pattern for shapes one and three on myDocument
.
Visual Basic for Applications |
---|
|
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.
Visual Basic for Applications |
---|
|
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:
Visual Basic for Applications |
---|
|
This example sets the fill pattern for the shapes named "Oval 4" and "Rectangle 5" on myDocument
.
Visual Basic for Applications |
---|
|
This example sets the fill pattern for shape one on myDocument
.
Visual Basic for Applications |
---|
|
This example creates an array that contains all the AutoShapes on myDocument
, uses that array to define a shape range, and then distributes all the shapes in that range horizontally.
Visual Basic for Applications |
---|
|
See Also