+ Reply to Thread
Results 1 to 2 of 2

Macro to Collapse pivot rows which don't have subrows?

  1. #1
    Forum Contributor michellepace's Avatar
    Join Date
    10-28-2015
    Location
    South Africa
    MS-Off Ver
    2013
    Posts
    132

    Question Macro to Collapse pivot rows which don't have subrows?

    Hi there,

    I've got a 3-level hierachy (Customer - Category - Product). Could someone please help to write a macro which will collapse any Categories which don't have Products (as highlighted in yellow below)?

    I think best explained by the screenshot . Sample book attached. I'd really appreciate any help. I've tried for a good two hours in order to do this but I'm chasing my tail.

    screenshot.png

    Best wishes,
    Michelle
    Attached Files Attached Files

  2. #2
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Macro to Collapse pivot rows which don't have subrows?

    The problem with collapsing the Category Row Field, is that it will collapse (or not) that field for all Customers.
    In my attachment, I've added a couple of rows which demonstrate this problem - try collapsing Category B for Customer 1, and you hide the valid products for Customer 2...

    It would be neater to load your Table data to the data model, then create an explicit DAX measure for the Sum Qty, which doesn't display individual blank product values:

    Please Login or Register  to view this content.
    Attached Files Attached Files
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

+ 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. Macro to toggle Pivot - Collapse/Expand entire field
    By rasonline in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 03-10-2024, 02:05 PM
  2. [SOLVED] VBA Macro to Collapse Rows Based on Value from Cell on another Worksheet
    By paintedapple in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-14-2017, 12:03 PM
  3. Link Pivot Table Collapse/Exapnd to worksheet rows
    By haroblueman in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-09-2016, 01:35 AM
  4. collapse columns in conjunction with a collapse rows macro
    By waternut in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-13-2015, 04:50 PM
  5. Macro to expand and collapse rows based on criteria in cells
    By jholiday78 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-26-2015, 10:32 AM
  6. Excel Macro to Collapse/Expand grouped rows and columns
    By magjayeck in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-28-2013, 10:58 AM
  7. macro to expand and collapse a pivot field failing.
    By dcgrove in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-01-2010, 02:30 PM

Tags for this Thread

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