Hi,
Need a little help to modify this code to do the following:
It needs to group all shapes that could be in each cell in column G (but only if it has more than one)
Each cell could have different shapes and number of shapes (a picture, ovals, arrows ..)
I tried to modify the original code from this thread to do so.
http://www.mrexcel.com/forum/excel-questions/505613-select-group-shapes-within-range-2.html
Need a little help to modify this code to do the following:
It needs to group all shapes that could be in each cell in column G (but only if it has more than one)
Each cell could have different shapes and number of shapes (a picture, ovals, arrows ..)
I tried to modify the original code from this thread to do so.
http://www.mrexcel.com/forum/excel-questions/505613-select-group-shapes-within-range-2.html
Option Explicit
Sub GroupShapesWithinCells()
Dim aShapes() As String
Dim oShape As Shape
Dim rRegion As Range
Dim Cnt As Long
Dim Rng As Range
Dim g As Range
For Each oShape In ActiveSheet.Shapes
If oShape.Type = msoGroup Then
oShape.Ungroup
End If
Next oShape
Set Rng = Range("G12", Range("G65536").End(xlUp))
For Each g In Rng
Cnt = 0
For Each oShape In ActiveSheet.Shapes
If Application.Union(g, Range(oShape.TopLeftCell, oShape.BottomRightCell)).Address = g.Address Then
Cnt = Cnt + 1
ReDim Preserve aShapes(1 To Cnt)
aShapes(Cnt) = oShape.Name
End If
Next oShape
If Cnt > 1 Then
ActiveSheet.Shapes.Range(aShapes).Group
End If
Next g
MsgBox "Done!"
End Sub