Accessing groups in sheet

MBjorn

New Member
Joined
Jun 1, 2011
Messages
10
Hi there,

I have a sheet with a number of groupes of shapes.

Is there a way to loop though all groups in a sheet/work book, like there is for say, checkboxes etc?

I'm am thinking like this:

Code:
for each group in WorkSheet.Groups
' ...
next group

This does not seem to work though.
Help much appreciated
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
This will loop through all checkboxes on a particular sheet.

Code:
Dim cBox As Checkbox

For Each cBox in Worksheets("Sheet1").DrawingObjects
'Some Code
Next
 
Upvote 0
I want to look through the groups, I used checkboxes as an example, because I know ti can be done for checkboxes
 
Upvote 0
As I understand it grouping shapes basically makes them one shape so looping through those should work?

Code:
For Each sh In Worksheets("Sheet1").Shapes
'Code
Next
 
Upvote 0
Looking through the Locals of a grouped shape I can't see anything that might help.

As you say you would probably need to ungroup them first.
 
Upvote 0
This example shows how to loop through the shapes in the first group in Sheet1. If these were say checkboxes then each checkbox value will be changed to True.

Code:
Sub Demo()
    Dim srng As ShapeRange
    Dim shp As Shape
    
    Set srng = Sheet1.Shapes.Range(1)
    
    For Each shp In srng.GroupItems
        Debug.Print shp.Name
        shp.OLEFormat.Object.Value = True
    Next shp
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,618
Messages
6,179,917
Members
452,949
Latest member
beartooth91

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