+ Reply to Thread
Results 1 to 5 of 5

VBA Outline Levels: Set Range in Function

  1. #1
    Registered User
    Join Date
    03-10-2024
    Location
    Berlin
    MS-Off Ver
    mac2016
    Posts
    94

    VBA Outline Levels: Set Range in Function

    Found this function on mrexcel:
    https://www.mrexcel.com/board/thread...evels.1061148/
    It lets you switch between your outline levels:
    Please Login or Register  to view this content.
    The code expands/collapses all your groups at once, though.
    Might there be a way to add an "input line" to set certain ranges of rows and columns?
    To say e.g. "rows 4-6" or "columns K-L"?
    (I haven't used any functions yet, I'm a bit overwhelmed.)

    Right now, I hide/unhide specific rows and columns with a "Flip Switch":
    Please Login or Register  to view this content.
    This works just fine, but takes quite some time to build.
    Set range, add rectangle (transparent) as button, create click, assign "call" to rectangle.
    For every group. And in the end, it's not even the real deal, e.g. it leaves certain cells "selected" (screenshot).
    And for now, this only allows me to switch between "Level closed" and "Level max expanded".
    I'd have to have extra sets of macros for every level, right?
    1) Set/Select range 2) Add rectangle 3) Create click 4) Assign to rectangle

    I've attached the workbook, all codes included.
    The merged cells with the double arrows are all working flip buttons, expanding and collapsing.

    So now I wonder, if that function can be tweaked?
    Might that result in less code?

    Thank you for any help!
    Last edited by briskie; 04-11-2024 at 10:56 PM.

  2. #2
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    2,047

    Re: VBA Outline Levels: Set Range in Function

    You can toggle to the ShowDetail property which will manipulate existing outlines.

    For example, the equivalent of your Flip_alpha would be as follows.

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    03-10-2024
    Location
    Berlin
    MS-Off Ver
    mac2016
    Posts
    94

    Re: VBA Outline Levels: Set Range in Function

    Wow!

    And might it be possible, to build a (one) button, which would loop through the levels?

    Can these be combined somehow?

    alpha Button 1 > equivalent to "Level 2"
    Please Login or Register  to view this content.
    alpha Button 2 > equivalent to "Level 3" and "Level 1" if collapsed
    Please Login or Register  to view this content.
    Thank you very much!

  4. #4
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    2,047

    Re: VBA Outline Levels: Set Range in Function

    I would probably do it like this.

    1) Make sure the shapes are sized to a single row or column.
    2) Add this Sub in a module to toggle the outlines

    Please Login or Register  to view this content.


    3) Run this sub once to give each shape a unique name and assign the ToggleOutline macro
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    03-10-2024
    Location
    Berlin
    MS-Off Ver
    mac2016
    Posts
    94

    Re: VBA Outline Levels: Set Range in Function

    Ok. Gave that a try, thank you very much!
    Unfortunately, this only allows you toggle between the two states "collapsed" and "max. expanded", no levels in between.

    I've managed to take all levels into consideration by building a macro for each level.
    With every level having its own button:

    Level 1: fully collapsed
    Level 2: what you have grouped in level 2
    Level 3: fully expanded

    For example, the levels "beta" look like this:

    beta Level 1:
    Please Login or Register  to view this content.
    beta Level 2:
    Please Login or Register  to view this content.
    beta Level 3:
    Please Login or Register  to view this content.
    As you can see, Level 2 consists of 3 ranges, the highlighted Level-2-range (= row 14) being in the middle.
    As far as I can tell from trying, the ShowDetail property doesn't allow you to do this.
    It seems to work with a/the corresponding row number automatically "assigned" by the group it consists of.

    With the ShowDetail property, you can say:

    beta Level 1:
    Please Login or Register  to view this content.
    beta Level 3:
    Please Login or Register  to view this content.
    Levels 1 and 3 work fine, since the ranges are not interrupted.
    But it seems, you can't set a range a) other than what your grouping consists of or b) an interrupted one.
    So Level 2 doesn't work this way.

    But: playing around with the function again, I came to realize, that it works with
    Please Login or Register  to view this content.
    instead of
    Please Login or Register  to view this content.
    I've tested the function again: it does exactly, what you would expect.
    The Outline Level property does take interrupted ranges into consideration.
    "Clicking" on Level 2, beta's Level 2 will be displayed, which is equivalent to row 14.

    So my guess is: if the function can be tweaked to work with ranges, this would be the neatest way to go.

    The function checks the whole worksheet:
    Please Login or Register  to view this content.
    How would you say "use this range", e.g. for beta:
    Please Login or Register  to view this content.
    Wouldn't this do?

    Thank you!
    Last edited by briskie; 04-15-2024 at 07:27 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Rolling Stock Levels for Assembly Component Levels
    By Keith650 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-27-2024, 04:30 PM
  2. Combining outline levels and autofilters
    By Kafrin in forum Excel General
    Replies: 1
    Last Post: 04-04-2011, 05:04 AM
  3. [SOLVED] Determining number of Outline levels
    By Keith in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-07-2006, 03:20 PM
  4. [SOLVED] How to Use Group and Outline function when locked sheet
    By Denis in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 06:05 AM
  5. How to Use Group and Outline function when locked sheet
    By Denis in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 04:05 AM
  6. How to Use Group and Outline function when locked sheet
    By Denis in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 12:05 AM
  7. [SOLVED] outline...hide levels
    By icebreaker914 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-24-2005, 04:05 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1