woipi
woipi

Reputation: 53

get single shape of selection

I am currently wondering if there is a way to get single objects (shapes) of a selection.

I have the following selection:

ActiveSheet.Shapes.Range(Array("feed", "000-100-SRC", "product")).Select

How do I get the name of the first item?

Upvotes: 0

Views: 397

Answers (2)

Patrick Lepelletier
Patrick Lepelletier

Reputation: 1652

basically your set of ranges is called a shaperange.

You can get its item like in any collection like : MyShaperange(1) , where myshaperange is a variable, or you replace it by activesheet.shapes(array("gggg","yyy"))(1)

If already selected, you can also: selection.shaperange(1) , but usually selecting ranges or shapes is not advised when coding.

Upvotes: 1

Storax
Storax

Reputation: 12177

Maybe like this

Sub Tester()

Dim v As Variant

    For Each v In ActiveSheet.Shapes.Range(Array("feed", "000-100-SRC", "product"))
        Debug.Print v.Name
    Next

End Sub

or like that

Sub Tester()

Dim vArr As Variant

    vArr = Array("feed", "000-100-SRC", "product")
    Debug.Print vArr(0)


End Sub

Upvotes: 1

Related Questions