Select a group of SHAPES by NAME

account123

New Member
Joined
Oct 1, 2016
Messages
11
Hi everyone...

I selected 5 shapes and defined a name in "Name Manger" the name is (MonthlyReports), iam trying to write a short code to make them all visible or not.

the code should look something like that

shapes.group("MonthlyReports").visible=false

and obviously it's not working,
 
Not sure that defining a name for the shapes is the way to go. Since you have only 5 shapes it should be very fast to loop through them. The code below (after you enter the proper shape names) should toggle your group between visible and hidden each time it is run.

Rich (BB code):
Sub test()
Dim shp  As Shape, Nms As Variant, i As Long
Nms = Array("Oval 1", "5-Point Star 3", "Isosceles Triangle 2") 'add shapes and change names to suit
For Each shp In ActiveSheet.Shapes
    For i = LBound(Nms) To UBound(Nms)
        If shp.Name = Nms(i) Then
            If shp.Visible = False Then
                shp.Visible = True
                Exit For
            Else
                shp.Select Replace:=False
                Exit For
            End If
        End If
    Next i
Next shp
On Error Resume Next
Selection.Visible = False
End Sub
 
Upvote 0
i have dozens of shapes so iam trying to name every bunch of them and just call for the whole group by name instead of calling for each shape
 
Upvote 0
i have dozens of shapes so iam trying to name every bunch of them and just call for the whole group by name instead of calling for each shape
Your OP indicated 5 shapes. Maybe someone else can help you.
 
Upvote 0
i have dozens of shapes so iam trying to name every bunch of them and just call for the whole group by name instead of calling for each shape
Select all of the shapes you want to be in a single group, then right-click one of the shapes and select "Group/Group" from the popup menu that appears, then type the name you want to give this group in the Name Box (field located next to the Formula Bar). Do that for each set of shapes you want to group. Now, you can hide all of the shapes in a single group (let's say you named it account123) with this code line...

ActiveSheet.Shapes("account123").Visible = False

and you can use True to show them again.
 
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top