+ Reply to Thread
Results 1 to 5 of 5

Excel 2007 : trying to hide columns depending on the number in a particular cell

  1. #1
    Registered User
    Join Date
    03-15-2010
    Location
    London,
    MS-Off Ver
    Excel 2007
    Posts
    20

    trying to hide columns depending on the number in a particular cell

    Hi

    In a spreadsheet I have columns H to GE (180 columns) highlighted yellow. What I would like to do is hide these columns depending on the value that I put in cell B4. So if I leave that cell blank, then all of the columns show. If I put a 1 in B4, only column H shows. If I put a 2, columns H and I show, and the rest are hidden, and so on, all the way upto 180, in which case all the columns show. Does anyone know how to do this? I'm using Excel 2007.

    Thanks
    Last edited by can2c; 03-15-2010 at 05:04 PM.

  2. #2
    Valued Forum Contributor mdbct's Avatar
    Join Date
    11-11-2005
    Location
    CT
    MS-Off Ver
    2003 & 2007
    Posts
    848

    Re: trying to hide columns depending on the number in a particular cell

    Right click on the tab where you would like the event to occur and choose View Code... Paste the following:

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    03-15-2010
    Location
    London,
    MS-Off Ver
    Excel 2007
    Posts
    20

    Re: trying to hide columns depending on the number in a particular cell

    Hi

    Thanks for this. It does work but there a couple of issues.

    If I put 0 in B4, it hides all columns from G to GE.
    If I put 1 in B4, it hides all columns from H to GE.
    If I put 2, just column H shows.

    Instead, I'd like that:

    when I put 0, no columns are hidden
    when I put 1, just column H shows
    when I put 2, columns H and I show
    etc

  4. #4
    Valued Forum Contributor mdbct's Avatar
    Join Date
    11-11-2005
    Location
    CT
    MS-Off Ver
    2003 & 2007
    Posts
    848

    Re: trying to hide columns depending on the number in a particular cell

    Try this version
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    03-15-2010
    Location
    London,
    MS-Off Ver
    Excel 2007
    Posts
    20

    Re: trying to hide columns depending on the number in a particular cell

    Yes! This is perfect. Thank you so much.

+ 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