+ Reply to Thread
Results 1 to 2 of 2

Macro to Group columns (same ones) across multiple sheets based on criteria

  1. #1
    Registered User
    Join Date
    05-15-2017
    Location
    London
    MS-Off Ver
    2013
    Posts
    12

    Macro to Group columns (same ones) across multiple sheets based on criteria

    Hi all

    I am in process of creating a template that can be used for business plan modelling and one of the things i hoped to add is a VBA macro that can group / ungroup certain columns upon pressing a button.

    The file will have multiple tabs but only some will need to be grouped (and these will always be in same format) whilst others wouldn't be (in workbook labelled "Other Stuff").

    The criteria for grouping would be if the column is showing Actual data or Forecast. In the attached workbook (light blue tabs) this can be seen in row 7 & 8 so in this instance columns F-Z would need to be grouped.

    In the attached workbook i've added an Overview tab where i've created the 2 buttons (as i believe this would be easier to write for) as well as listed the workbook tabs. I've added criteria on whether they should be grouped or not - for testing purposes. Ideally as the workbook grows i could just adjust the macro to incorporate the new additional tabs/sheets.

    I've never written macros myself and all the google searching ive done has produced code that has gone way over my head / is limited to instances for single tabs so any help would be greatly appreciated.

    I tried doing basic version by simply recording the action but whilst this would group the columns it wouldnt "hide detail" despite doing that whilst recording. plus it wouldnt be dynamic based on changing column requirements unless changed manually in VBA each time.

    Many thanks for any responses / suggestions!
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    05-15-2017
    Location
    London
    MS-Off Ver
    2013
    Posts
    12

    Re: Macro to Group columns (same ones) across multiple sheets based on criteria

    hi guys.

    so i managed to make it so that the macro groups & hide details and then unhides details and ungroups (2 seperate macros) however it is currently not dynamic.
    its basically a repeat of the 5 tabs ive chosen so far and the columns are are manual:

    Group code:

    Please Login or Register  to view this content.
    Ungroup code:

    Please Login or Register  to view this content.
    I've also had partial success using the following:

    Please Login or Register  to view this content.
    The second one is more closer to what i need (although would prefer group rather than hidden) since it uses a criteria (ie if row contains "Actual" then hide") however i've now began encountering errors...perhaps due to C&P buttons and modules getting mixed up and sometimes these macros no longer work. will see if deleting everything and starting again fixes it but in the mean time any advice on how to improve / simply this would be greatly appreciated.
    Last edited by ExcellingOcfUpsides; 10-31-2019 at 11:36 AM.

+ 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. [SOLVED] Macro to group / ungroup columns on multiple sheets
    By yllew in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-01-2018, 06:40 PM
  2. [SOLVED] Need macro to copy data from 1 sheet to multiple sheets based on certain criteria
    By JudyF in forum Excel Programming / VBA / Macros
    Replies: 24
    Last Post: 11-08-2017, 10:34 AM
  3. [SOLVED] Macro to Hide Columns in All Sheets based on criteria in Sheet1
    By toci in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 03-30-2016, 08:38 PM
  4. Replies: 5
    Last Post: 01-04-2016, 01:42 PM
  5. Replies: 0
    Last Post: 02-28-2013, 07:28 AM
  6. [SOLVED] Macro to group columns based on specific criteria in entire workbook
    By kbkumar in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-09-2012, 04:47 AM
  7. Macro to Segregate the data based on Multiple Criteria's in Multiple Columns -Challenging!
    By Novice_To_Excel in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-08-2012, 07:31 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