+ Reply to Thread
Results 1 to 5 of 5

Using an If then statement to hide a column in VBA

  1. #1
    Registered User
    Join Date
    06-19-2013
    Location
    New York, New York
    MS-Off Ver
    Excel 2010
    Posts
    4

    Using an If then statement to hide a column in VBA

    Hi,

    I am looking to use VBA to hide a column based on the value of another column.

    For example, if column G = "Yes", then Hide Column U and If Column G = "No" then Hide column W.

    I'm sure this is not very complex but I am just getting started using VBA.

    Thank you for your help!!

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: Using an If then statement to hide a column in VBA

    Yes or No would be in cell G1 for this example

    Please Login or Register  to view this content.
    If-Then is not really necessary in this case as you've defined the problem.
    Last edited by AlphaFrog; 06-19-2013 at 05:52 PM.

  3. #3
    Registered User
    Join Date
    06-19-2013
    Location
    New York, New York
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Using an If then statement to hide a column in VBA

    Makes sense...however I am running into another issue which I believe is the cause of it not working with the above statement.

    Column G, the driver, consists of either yes or no in cells G2-G578. However, after running a macro prior to the one that I have a question about above, either "yes" or "no" will be displayed, the other cells will be hidden based on a filtering scheme. I guess my question is what would the proper syntax be to base the the hiding of column U or W off of only the values that are being shown?

    Thank you anyone who can help!!!

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: Using an If then statement to hide a column in VBA

    Quote Originally Posted by MrExcel6543 View Post
    Makes sense...however I am running into another issue which I believe is the cause of it not working with the above statement.

    Column G, the driver, consists of either yes or no in cells G2-G578. However, after running a macro prior to the one that I have a question about above, either "yes" or "no" will be displayed, the other cells will be hidden based on a filtering scheme. I guess my question is what would the proper syntax be to base the the hiding of column U or W off of only the values that are being shown?

    Thank you anyone who can help!!!
    This will Show\Hide the two columns based on the value in the first visible cell in G2:G578

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    06-19-2013
    Location
    New York, New York
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Using an If then statement to hide a column in VBA

    Last question...

    How would I change it so the logic is based on other columns hidden

    So essentially I need if either G or I are visible....hide W
    if either H or J are visible....hide U

    THANKS!!!

+ 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