+ Reply to Thread
Results 1 to 6 of 6

Hiding Columns based on References

  1. #1
    Registered User
    Join Date
    01-22-2013
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    55

    Hiding Columns based on References

    Hi all,

    Thanks for taking the time to read this.

    My macro brain is falling a bit short on this one and would appreciate any help!

    In a worksheet in row 1 from columns C to Z for example, is a set of data with a number in each column in ascending order however the same number can occur multiple times.

    For example:

    C D E F G H I J K L M N ...
    1 1 2 2 2 3 3 3 3 4 5 5

    Based on two cells in cells A1 and A2 I would like to hide columns not containing the range on numbers covered including and between those in A1 and A2.

    Cell A1 would be the starting point - for example number 2.

    Cell A2 would be the ending point - for example number 4.

    The result would be:

    E F G H I J K L
    2 2 2 3 3 3 3 4


    I believe the macro would be worksheet > change based on these cells.

    I believe the best way to make it run is to populate cell A1 runs first, hiding everything except that number.

    Then populate cell A2, unhiding from the number in A1 to the number in A2.


    Im open to better ways of accomplishing this!


    Any input would be greatly appreciated!


    Many thanks in advance,


    Coeus.

  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: Hiding Columns based on References

    Something like:
    Please Login or Register  to view this content.
    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...

  3. #3
    Forum Expert
    Join Date
    08-02-2013
    Location
    Québec
    MS-Off Ver
    Excel 2003, 2007, 2013
    Posts
    1,412

    Re: Hiding Columns based on References

    Hi Coeus,
    Something like this?

    Please Login or Register  to view this content.
    GC Excel

    If this post helps, then click the star icon (*) in the bottom left-hand corner of my post to Add reputation.

  4. #4
    Registered User
    Join Date
    01-22-2013
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    55

    Re: Hiding Columns based on References

    Hi Olly and GE Excel,

    Many thanks for your fast replies.

    I'm reading through and get the basics of these, the macro type, defining variables, for, next, if etc.

    Im not sure on how 'If Not Intersect...' and subsequent parts works.

    Would you mind posting or adding comments to better help me understand how this all works? I try not to blind copy any feedback otherwise how would one learn!


    Again many thanks for your input,


    Coeus.

  5. #5
    Registered User
    Join Date
    01-22-2013
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    55

    Re: Hiding Columns based on References

    Hi GC,

    Just tried testing yours - it seems to hide the columns I want shown i.e. for 2 and 4 in cells A1 and A2 its only any columns with 2's, 3's and 4's I would like shown.

    Would you mind re-posting / amending your macro and Ill give that a whirl!

    Many thanks again,


    Coeus.

  6. #6
    Registered User
    Join Date
    01-22-2013
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    55

    Re: Hiding Columns based on References

    One last level to add onto this...

    Say I were to change cells A1 and A2 to weeks e.g. WEEK1, WEEK2, WEEK3 etc. and each reference was in the same format e.g.:

    A B C D E
    WEEK 1 WEEK 1 WEEK 2 WEEK 3 WEEK 4

    Would you need to change 'c' variable to say the =RIGHT(range, 1) or something along those lines?


    Many thanks,


    Coeus.

  7. #7
    Registered User
    Join Date
    01-22-2013
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    55

    Re: Hiding Columns based on References

    Hi all,

    I have modified the macro for the layout of the worksheet and to try to achieve the hiding desired.

    Can you please review as this is not working :-(

    Please Login or Register  to view this content.
    The references it is benchmarking against in B7 to B8 is in the format WK01, WK02 etc. hence the RIGHT(xxx, 2) to split just the numbers out.


    Again any input would be greatly appreciated!


    Coeus.

+ 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. Hiding Columns based on Cell Value
    By Dynamo418 in forum Excel General
    Replies: 1
    Last Post: 08-08-2012, 08:21 PM
  2. Hiding columns based on a header value
    By numbers2 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-24-2012, 10:16 PM
  3. Un-Hiding and Hiding Columns based on Drop-Down Values in a Column.
    By e4excel in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 10-30-2011, 09:24 AM
  4. Un-Hiding and Hiding Columns based on Drop-Down Values in a Column.
    By e4excel in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-11-2011, 06:49 AM
  5. hiding rows based on two columns
    By Marcus Gee in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-14-2007, 10:35 AM

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