0

I have grouped some shapes, and if the user selects a shape within a group I want to "Select the Group" (to avoid them moving part of the group and creating a mess). How do I get the name of the "Group" if a shape within the group is selected? I have tried looking in "Activesheet", "Selection" and "Shapes" etc.

1
  • I think the issue is more how are you going to trap the fact they selected an item at all. To get the name of the group a simple selection.shaperange.parentgroup.name with an error handler should suffice.
    – Rory
    Sep 7, 2022 at 14:21

1 Answer 1

0
Sub GetShapeGroupName()

Dim s1 As Shape, s2 As Shape
Dim SelectedGroup As String

For Each s1 In ActiveSheet.Shapes
    With s1
        If .Type = msoGroup Then
            For Each s2 In .GroupItems
                If s2.Name = Selection.Name Then SelectedGroup = .Name
            Next s2
        End If
    End With
Next s1

Debug.Print SelectedGroup

End Sub

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.