+ Reply to Thread
Results 1 to 5 of 5

How to hide columns based on a cells value in that column?

  1. #1
    Registered User
    Join Date
    05-28-2015
    Location
    Cardiff, Wales
    MS-Off Ver
    MS Office 2010
    Posts
    5

    How to hide columns based on a cells value in that column?

    I am a fairly basic Excel user and I know this has been looked at and answered several times previously but I've tried several different pieces of code and none of them appear to work for me - probably my bad.

    I want to hide a column if the value of a particular cell in that column is set to "OK". The value of the cell is set by the formula: =IF(C39>=C18,"OK","Needs Cover") and is for the range of cells (and thus columns) C17:AX17.

    Do I need a Macro, some VBA, a module or something else and if so has anyone:
    1. got a nice piece of code I'd be able to use and
    2. how would I insert it into my worksheet?

    Many thanks in advance.

  2. #2
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: How to hide columns based on a cells value in that column?

    1. In Excell, Press Alt + F11. The VBA editor window will appear
    2. On the left hand side, locate the Project explorer panel
    3. Find your woekbook, click the "+" to expand it if not already expanded
    4. Locate the sheet object you want the code to run on, then double click that sheet
    5. In the white area to the right, paste the code below:

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    05-28-2015
    Location
    Cardiff, Wales
    MS-Off Ver
    MS Office 2010
    Posts
    5

    Re: How to hide columns based on a cells value in that column?

    Hi walruseggman,

    Thank you very much for the quick response. As I said I am a basic user, the code works great when I press return on an individual cells formula, is there any way to make all the columns hide at the same time? Even better with a "hide button" of some description.

    Thanks again,

    dougielb

  4. #4
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: How to hide columns based on a cells value in that column?

    Sure. Insert a button and assign the following code to it ( a form control button will suffice):

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    05-28-2015
    Location
    Cardiff, Wales
    MS-Off Ver
    MS Office 2010
    Posts
    5

    Re: How to hide columns based on a cells value in that column?

    Hi walruseggman,

    Thank you even more. I was walking out the door last night when my email pinged so I have only just checked your latest post - it is awesome! The manager who asked for this will be thrilled! I have learned a lot already from you - I managed to put in a second button to unhide the columns as well.

    Once again thank you for your time and patience with a learner - if I knew how to highlight this thread on the internet I would as it is the easiest code I've seen to achieve this (and the only one that works!).

    dougielb

+ 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. Hide/show columns based on the year in the header of the column
    By lukelucky in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-19-2015, 04:03 AM
  2. Code to hide columns based on value of another column
    By Saeber4777 in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 08-02-2014, 01:41 AM
  3. Hide and unhide columns based on value of 0 or 1 (respectively) in cells G1:LG1
    By cplawren in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-22-2012, 01:58 AM
  4. Macro to hide columns based on cell values in the column to be hidden
    By JCMus in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-15-2012, 06:06 PM
  5. Macro to hide columns based on contents of two cells
    By Korae13 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-18-2006, 12:40 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