Ungrouping entire sheet by macro

L

Legacy 96851

Guest
Almost made it through the day without asking anything. At least the questions are getting more trivial.

I have a macro that pretty much groups every 6 rows in a couple of worksheets. I want to be able to run the macro multiple times on the same workbook, but as you can imagine, I don't want the grouping to happen again. At the beginning of the code I have
Code:
With .UsedRange
        .ClearContents
        .ClearFormats
        .FormatConditions.Delete
        .Ungroup
End With
This, however, doesn't ungroup anything.

Is there a way to A.) ungroup all grouped rows in the sheet or B.) check if a range/row is grouped, something like IsNumeric() but for groups.
Thanks in advance, because I'm sure someone will know!
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Code:
On Error Resume Next
Sheets("sheet1").Range("A1:IV65536").Ungroup

EDIT: -- error -- doesn't seem to work more than once...below does work...

Code:
On Error Resume Next
Cells.Rows.Ungroup
Cells.Columns.Ungroup
 
Last edited:
Upvote 0
Hmm... Still doesn't work the way it should. I think my problem might be that they stay hidden even after ungrouping. Will try undoing that as well.

No, macro still doesn't work at all. I guess it has nothing to do with groups and must be something else in my code being an idiot, though I'm not sure why. Thanks anyway.
 
Last edited by a moderator:
Upvote 0
can't you just use

Code:
Cells.Rows.Hidden = False
Cells.Columns.Hidden = False

to unhide any grouped rows/columns ?
 
Upvote 0
Actually, I just figured it out. (it had to do with a wonky conditional statement, though it was mostly the unhiding thing).

Sorry for not posting the code, it was a good two pages long and I didn't think it was worth going through and weeding out all the parts you may or may not need to see in order to help. I do usually try to post it when I can. Thanks for the effort though, you at least clarified that what I thought was wrong wasn't it.
 
Upvote 0

Forum statistics

Threads
1,214,665
Messages
6,120,803
Members
448,990
Latest member
rohitsomani

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top