• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 351
  • Last Modified:

Expand a single collapsed range in VBA?

Hello - I have a worksheet that can wind up with several collapsed ranges, and in a particular situation, I would like to expand one particular range.

I am already using MyWorksheet.Outline.ShowLevels RowLevels:=x to expand all ranges at once

Should/Could this work on a specified range?

Thanks
0
mlagrange
Asked:
mlagrange
  • 2
  • 2
1 Solution
 
Shanan212Commented:
Unfortunately, you cannot reference specific group but rather the levels.

Only way is to ungroup them and re-group them as here

    With Range("B:D").Rows
        .Ungroup
            'Do whatever you want to here
        .Group
    End With

Open in new window

0
 
mlagrangeAuthor Commented:
Well, I don't want to lose the grouping; I just want to expand
0
 
Shanan212Commented:
You will loose the grouping temporarily though...so fast, you wouldnt even realize because macro will

Ungroup
Group back
0
 
mlagrangeAuthor Commented:
Sorry - I should have described what I needed more clearly.

This spreadsheet loads up records from a database, in several sections, and then groups & collapses the groups.

The user would expand a given group to make changes or additions to individual records in that group, which might then require changes to records in another group.  

I would like to expand just that one group where they might need to make related changes, without losing the expand/collapse capabilty, so they can collapse it again if they want.  

I admit I haven't tried your code; maybe .Ungroup expands, and .Group just groups, without collapsing? I'll give it a shot

Thanks
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now