+ Reply to Thread
Results 1 to 5 of 5

Grouping columns based on a value in a cell

  1. #1
    Registered User
    Join Date
    06-20-2008
    Posts
    3

    Grouping columns based on a value in a cell

    Hi

    This may be a simple piece of code, but I am new to VBA so any help will be greatly appreciated!

    I have one row, which every 6th cell (e.g. F1) either contains the word "Group" or "Don't Group" based on an if statement about the contents of the previous 5 cells (e.g. cells A1:E1).

    e.g. if all cells A1:E1 say "yes", then F1 says "Group". Otherwise, it says "Don't Group".

    This group of 6 cells is repeated along the row multiple times (up until cell FF1).

    What I want is a macro that will go along this row, and every time it sees the word "Group", will group together the 5 previous columns (the ones which say "yes") only leaving the one which says "Group" visible.

    I want to group the columns as opposed to hide them as it may be necessary for someone to come along later and review the file, therefore i want to make it easy to view the columns which will not be visible.


    Thanks for your help
    Rob

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    If you placed the data in rows instead of columns you could use AutoFilter.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    06-20-2008
    Posts
    3
    thanks roy

    unfortunately i can't do that.

    Each of the first 5 columns represents a day of the working week.

    Under each day there are more data entries than there are columns wide in an excel sheet
    i.e. if i transpose my table, it simply won't fit!

    Rob

  4. #4
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Maybe


    Please Login or Register  to view this content.
    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  5. #5
    Registered User
    Join Date
    06-20-2008
    Posts
    3
    thank you thank you thank you both,

    it works a treat, and has made my life a lot easier!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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