the shapes are in cells in column B then this code will work.
Sub test()
Dim shp As Shape, shpU As Shape
Dim vArray(), vR()
Dim Ws As Worksheet, rng As Range
Dim n As Long, k As Integer
Dim v As Variant
Set Ws = ActiveSheet
Ws.Shapes.SelectAll
Selection.Ungroup
For Each shp In Ws.Shapes
n = n + 1
ReDim Preserve vArray(1 To n)
vArray(n) = shp.Name
Next shp
For Each rng In Ws.Range("b1:b1000")
k = 0
For Each v In vArray
If Not Intersect(Ws.Shapes(v).TopLeftCell, rng) Is Nothing Then
k = k + 1
ReDim Preserve vR(1 To k)
vR(k) = v
End If
Next v
If k > 1 Then
Ws.Shapes.Range(vR).Group
End If
Next rng
End Sub
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…