stirlingmw1
Board Regular
- Joined
- Jun 17, 2016
- Messages
- 53
- Office Version
- 2016
- 2013
- 2010
- 2007
- Platform
- Windows
Morning All
I have a worksheet with multiple Shapes. These Shapes are named "Cause1", "Cause2", Cause3" etc. The number of these Shapes is based on the number of Rows of Data present in Column C. I have other Shapes but with different names based on data from other Columns I am trying to select all of the Shapes that contain the name "Cause" so that I can Group them to see the Total Height of these Shapes and the Gaps in between them. I will then Use the Centre point of this group as the Top position of another Shape. The Code I am trying to get to work is below, but does not seem to work.
Any ideas what I am doing wrong or another way I should be thinking about it?
Thanks
Steve
I have a worksheet with multiple Shapes. These Shapes are named "Cause1", "Cause2", Cause3" etc. The number of these Shapes is based on the number of Rows of Data present in Column C. I have other Shapes but with different names based on data from other Columns I am trying to select all of the Shapes that contain the name "Cause" so that I can Group them to see the Total Height of these Shapes and the Gaps in between them. I will then Use the Centre point of this group as the Top position of another Shape. The Code I am trying to get to work is below, but does not seem to work.
VBA Code:
NumOfCauses = ActiveSheet.Range("C2").End(xlDown).Row - 1
For i = 1 To NumOfCauses
For Each Sh In ActiveSheet.Shapes
If Sh.Name = "Cause" & i Then Sh.Select True
Next
With Selection
.Group
End With
Next i
End Sub
Any ideas what I am doing wrong or another way I should be thinking about it?
Thanks
Steve