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

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.

DonkeyOte

MrExcel MVP
Joined
Sep 6, 2002
Messages
9,124
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
L

Legacy 96851

Guest
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

DonkeyOte

MrExcel MVP
Joined
Sep 6, 2002
Messages
9,124
can't you just use

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

to unhide any grouped rows/columns ?
 
Upvote 0
L

Legacy 96851

Guest
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,191,706
Messages
5,988,187
Members
440,136
Latest member
dandanfielding

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
Top