+ Reply to Thread
Results 1 to 7 of 7

Hiding/showing columns based on dependent list

  1. #1
    Registered User
    Join Date
    06-17-2018
    Location
    Oregon
    MS-Off Ver
    Office Pro Plus 2016
    Posts
    3

    Hiding/showing columns based on dependent list

    Hello, Excel-ers! I have a question that I'm hoping someone can help with.

    I have created a set of dependent drop down lists in subsequent columns. In other words, Column A has a dropdown list with options Yes, No, or Maybe. In Column B, if Yes or No is selected in Column A, another drop-down list appears. In Column C is yet another drop down list, based on the selection in Column B.

    So far, so good. What I was trying to figure out is if I can hide columns (or unhide columns) B and C depending on what is selected in Column A. For example, if Yes is selected in Column A, I'd like Column B to be unhidden - but for Column B to stay hidden if Maybe is selected.

    I got the VBA code to work for the above. However, once I select something from the dropdown menu in Column B, it goes back to being hidden. I can't figure out why. I'd like for that Column to stay visible once a selection is made.

    Any ideas would be greatly appreciated!!

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,420

    Re: Hiding/showing columns based on dependent list

    Attach a sample workbook (not a picture or pasted copy). Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,420

    Re: Hiding/showing columns based on dependent list

    Ideally, for those of us using iPads, also post the code separately (using Code Tags)

  4. #4
    Registered User
    Join Date
    06-17-2018
    Location
    Oregon
    MS-Off Ver
    Office Pro Plus 2016
    Posts
    3

    Re: Hiding/showing columns based on dependent list

    Attached is the file, with three examples - the first with nothing selected in Column B, the second has selections in Column B that would not prompt further action, and the third has selections in Column B that should cause Columns C and D to be visible; however, once you make a selection in Column C or D it causes them to be hidden again.

    Here's the code.

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by acarrier1868; 06-18-2018 at 10:17 AM.

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,420

    Re: Hiding/showing columns based on dependent list

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Click on Edit to open your thread, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    That said, try:

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    06-17-2018
    Location
    Oregon
    MS-Off Ver
    Office Pro Plus 2016
    Posts
    3

    Re: Hiding/showing columns based on dependent list

    Thank you, TMS. My apologies - I almost never use macros. I edited my post above.

    Thank you for your suggestion - that seems to have done it. Of course, in doing so I realized the fallacy of my intent - since there are dozens of rows in each sheet, "No" is bound to be selected at some point, so the following columns will be visible throughout - making the hiding of them a moot point.

    It was a nice theory, while it lasted...

  7. #7
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,420

    Re: Hiding/showing columns based on dependent list

    You're welcome.


    I edited my post above.
    Thank you for that

    As a suggestion, you could colour/black out and/or lock the cell(s). However, you would need to protect the sheet for this to be effective.


    If you are satisfied with the solution(s) provided, please mark your thread as Solved.


    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save


    You may also want to consider thanking those people who helped you by clicking on the little star at the bottom left of their reply to your question.

+ 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 drop down list selection
    By acadzow in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-26-2015, 01:29 AM
  2. Hiding or showing rows based on contents of multiple columns
    By armsaw in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-07-2013, 02:11 AM
  3. [SOLVED] Hiding Columns based on the value of a drop down list
    By ExcelNewbie2534 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-18-2012, 07:03 PM
  4. Hiding Columns based on Drop Down list selection
    By forge13 in forum Excel General
    Replies: 5
    Last Post: 11-25-2011, 07:39 AM
  5. hiding / showing columns...
    By LSB M in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 07-07-2008, 05:50 PM
  6. Hiding/Unhiding columns based on a dropdown list
    By jim_0068 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-12-2007, 11:57 AM
  7. [SOLVED] Showing or Hiding rows based on data validation list
    By Magnet Peddler in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-12-2006, 04:40 PM

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