対象のエクセルの1枚目のシートに存在する全オートシェイプについて
グループ化解除できなくなるまでグループ化解除する。
Function ungroopAllMsoGroup()
Dim grp_flg As Boolean
Dim shp As Shape
Dim mwbk As Workbook
Set mwbk = ThisWorkbook
grp_flg = True
Do While grp_flg = True
grp_flg = False
For Each shp In mwbk.Sheets(1).Shapes
If shp.Type = msoGroup Then
shp.Ungroup
grp_flg = True
Else
End If
Next shp
Loop
End Function
ループ処理に入った段階でグループ化フラグをfalseにしています。
ひとつでもグループ化されたオブジェクトがあればフラグをtrueにし、
次のループ処理でグループ化されたオブジェクトが残っているかを判定しています。