+ Reply to Thread
Results 1 to 5 of 5

Hide Columns based on drop down selection

  1. #1
    Registered User
    Join Date
    05-04-2018
    Location
    Sydney, Australia
    MS-Off Ver
    2016
    Posts
    65

    Hide Columns based on drop down selection

    Hi Everyone,

    I have attached a sample file where I want to hide the rows based on the drop down selection.

    If I select "N" in cell F4 then I want to hide all the columns from BH to FG.
    Then If I select "Y" in cell F4 then the VBA should look at cell F6 which has a drop down with numbers ranging from 1 to 104 and based on the selection in cell F6 I should be able to see only the number of columns selected.

    I have gone this far with the VBA code but it doesn't work when the drop down number changes each time in cell F6. I also think there would be a way to do with a smaller VBA code. I have attached the file I am working on at the moment.

    Please Login or Register  to view this content.
    Thanks again. Hoping to get this sorted with someones help.

    Cheers,
    Piyush
    Attached Files Attached Files

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

    Re: Hide Columns based on drop down selection

    Hello,

    Here's how I would do it :

    Please Login or Register  to view this content.
    Last edited by GC Excel; 08-06-2019 at 10:03 PM. Reason: typo in code, wrong columns...
    GC Excel

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

  3. #3
    Registered User
    Join Date
    05-04-2018
    Location
    Sydney, Australia
    MS-Off Ver
    2016
    Posts
    65

    Re: Hide Columns based on drop down selection

    Thank you so much. this works great. I have another question on this thing.

    How can I make this work together with another drop down selection that I want to use to hide some columns.

    In cell E4 is I select N then I want to hide columns H to BH and then if I select Y in cell E4 then it should look at cell E6 which has again drop down with numbers and I want to hide columns to the left based on my selection. For Example: I select 10 in cell E6 then I should only be able to see columns BG to AX (count to the left) and so on.

    Is this achievable.

    Thanks again

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

    Re: Hide Columns based on drop down selection

    Hello,

    Yes this is doable. Approach is slightly different because you want to show the columns to the left.
    So you need to use the OFFSET function to first 'move' the starting point, the RESIZE to show the amount of column to show.

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    05-04-2018
    Location
    Sydney, Australia
    MS-Off Ver
    2016
    Posts
    65

    Re: Hide Columns based on drop down selection

    thank you. This works like charm and exactly like I wanted. Thanks again.

+ 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. help please - hide unhide rows and columns based on drop down selection
    By iamgujju in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 07-01-2019, 10:56 AM
  2. Hide/Unhide Columns based on Drop-Down Selection
    By Khafez in forum Excel General
    Replies: 21
    Last Post: 09-14-2016, 12:13 PM
  3. [SOLVED] Hide Columns that do not = drop down menu selection
    By Invicta084 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-14-2015, 09:47 AM
  4. [SOLVED] Vba to hide columns based on drop down selection
    By Nicola13 in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 09-18-2012, 05:42 AM
  5. Hide a row based on a drop down menu selection
    By AMechEng in forum Excel General
    Replies: 4
    Last Post: 06-20-2012, 03:57 AM
  6. [SOLVED] Hide columns depending on a text selection in a drop-down list
    By hvide makelele in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-08-2012, 04:00 PM
  7. Hide certain rows based on drop box selection
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-19-2010, 09:09 AM

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