N
Nick Junod
Hello,
I'm an intermediate user of macros and VBA programing but I can't figure
this out. I want to create a macro that will identify if I have selected
rows or columns and if what I've selected is grouped or not and then either
group the selection or ungroup the selection based on these answers. This is
what I've built...obviously it doesn't work. Please help if you can.
Sub GroupUngroupSelection()
With selection
If Selection.Rows = True
If Selection.Rows.Group = True
selection.Rows.Ungroup
Else:
selection.Rows.Group
Elseif Selection.Columns = True
If Selection.Columns.Group = True
selection.Columns.Ungroup
Else:
selection.Columns.Group
End With
End Sub
I'm an intermediate user of macros and VBA programing but I can't figure
this out. I want to create a macro that will identify if I have selected
rows or columns and if what I've selected is grouped or not and then either
group the selection or ungroup the selection based on these answers. This is
what I've built...obviously it doesn't work. Please help if you can.
Sub GroupUngroupSelection()
With selection
If Selection.Rows = True
If Selection.Rows.Group = True
selection.Rows.Ungroup
Else:
selection.Rows.Group
Elseif Selection.Columns = True
If Selection.Columns.Group = True
selection.Columns.Ungroup
Else:
selection.Columns.Group
End With
End Sub