grouping and outliining

  • Thread starter Thread starter Robert Flanagan
  • Start date Start date
R

Robert Flanagan

How can I determine if a user has applied Data, Group and Outline, Group to
any rows on a worksheet, and then if true, remove just that grouping?

Bob
 
The only way I know is by checking the .EntireRow.OutlineLevel property of
a cell in the row. If the row is part of one or more groups its OutlineLevel
will be greater than 1. You should note that the last row in a group (the
"anchor" row which shows the plus/minus box next to it) is NOT part of the
group as far as the OutlineLevel is concerned.

If you ungroup a single row from the middle of a group, you split the group
into two groups. The row you ungrouped becomes the "anchor" row for the group
above it, and the grouped rows below it become a new group (if the row is prt
of multiple groups, only the lowest-level grouping is affected). You can't
easily restore it exactly the way it was, so this seems like a pretty odd
thing to do. I generally just remove all the user's grouping on the sheet if
it is going to interfere with the processing I need to do.

Cells.Rows.Ungroup will remove one level of grouping at a time from an
entire worksheet. To be sure you have removed all the grouping you will have
to find the row with the highest OutlineLevel, then run the command above
until that row's OutlineLevel is 1. Even if you are just removing the
grouping from a single row you need to ungroup it until its OutlineLevel is 1.

Hope this helps,

Hutch
 
Back
Top