Solved

Expand a single collapsed range in VBA?

Posted on 2013-01-18
4
259 Views
Last Modified: 2013-01-28
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
Comment
Question by:mlagrange
  • 2
  • 2
4 Comments
 
LVL 13

Expert Comment

by:Shanan212
Comment Utility
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
 

Author Comment

by:mlagrange
Comment Utility
Well, I don't want to lose the grouping; I just want to expand
0
 
LVL 13

Accepted Solution

by:
Shanan212 earned 500 total points
Comment Utility
You will loose the grouping temporarily though...so fast, you wouldnt even realize because macro will

Ungroup
Group back
0
 

Author Comment

by:mlagrange
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now