+ Reply to Thread
Results 1 to 16 of 16

Hide/Unhide columns in multiple worksheets based on item chosen in a drop down list.

  1. #1
    Registered User
    Join Date
    02-26-2014
    Location
    Guelph, Ontario
    MS-Off Ver
    Excel 2010
    Posts
    9

    Question Hide/Unhide columns in multiple worksheets based on item chosen in a drop down list.

    Hello everyone,

    I am hoping to create a drop down list of months in one sheet, and when I select a certain month, columns in about 10 other worksheets in the same workbook will either hide or unhide columns...

    The spreadsheet is laid out with columns (C-N) for each month in the year, for actuals, then columns for budget and budget variance (O-P), then YTD Actual, YTD Budget and YTD Variance. When I select September, for example, I want October-December to hide, and leave Jan-Sep unhidden, while keeping the budget, YTD and variance columns.

    Is there a VBA code that can achieve this? I have searched through old threads and can't seem to find something identical to this issue.

    Please help.

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,876

    Re: Hide/Unhide columns in multiple worksheets based on item chosen in a drop down list.

    Attach a sample workbook. Make sure there is just enough data to make it clear what is needed. 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 demonstrated, mock them up manually if needed. Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Registered User
    Join Date
    02-26-2014
    Location
    Guelph, Ontario
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Hide/Unhide columns in multiple worksheets based on item chosen in a drop down list.

    Sorry about that.. see attached..

    I want a command to select a month is the "month" tab, and then the next few tabs after it will update there formatting. In my actual file, there are about 10 tabs that need to change.

    Thanks for the quick reply. Let me know if this is possible.
    Attached Files Attached Files

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,876

    Re: Hide/Unhide columns in multiple worksheets based on item chosen in a drop down list.

    Try this:

    Please Login or Register  to view this content.

    How to install your new code
    1. Copy the Excel VBA code
    2. Select the workbook in which you want to store the Excel VBA code
    3. Press Alt+F11 to open the Visual Basic Editor
    4. Choose Insert > Module
    5. Edit > Paste the macro into the module that appeared
    6. Close the VBEditor
    7. Save your workbook (Excel 2007+ select a macro-enabled file format, like *.xlsm)

    To run the Excel VBA code:
    1. Press Alt-F8 to open the macro list
    2. Select a macro in the list
    3. Click the Run button

  5. #5
    Registered User
    Join Date
    02-26-2014
    Location
    Guelph, Ontario
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Hide/Unhide columns in multiple worksheets based on item chosen in a drop down list.

    Thanks alansidman

    I got a runtime error '9' message when I tried running it. When I went to debug, it highlighted the Set w = Sheets("Month") line. Do you know what might be causing the issue?

    Thank again for being so helpful with this.

  6. #6
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,876

    Re: Hide/Unhide columns in multiple worksheets based on item chosen in a drop down list.

    Do you have a sheet called Month as you did in the example? I tested on the workbook you attached and it worked perfectly.

  7. #7
    Registered User
    Join Date
    02-26-2014
    Location
    Guelph, Ontario
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Hide/Unhide columns in multiple worksheets based on item chosen in a drop down list.

    Sorry about that.. I see what you mean.

    I've attached the file I'm actually working on, and just deleted the content. There are 12 tabs (after the Month tab) that I am hoping will change.. I have the VBA code you provided me in this file.. can you test it and let me know if it will still work?
    Attached Files Attached Files

  8. #8
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,876

    Re: Hide/Unhide columns in multiple worksheets based on item chosen in a drop down list.

    The structure of your new file is slightly different. Additional sheets that don't need to have hides and the columns are in different locations. Have a few things I need to take care away from PC. Will work on making changes tonight. Should not be to rigorous.

    In the future, you are always better off providing a realistic sample the first go around. Avoids wasting time and effort working on projects that later need to be redone.
    Last edited by alansidman; 02-26-2014 at 06:08 PM.

  9. #9
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,876

    Re: Hide/Unhide columns in multiple worksheets based on item chosen in a drop down list.

    Here you go. I added a couple of buttons to make it even easier to manipulate.
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    02-26-2014
    Location
    Guelph, Ontario
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Hide/Unhide columns in multiple worksheets based on item chosen in a drop down list.

    This is perfect.. thanks again for all your help with this.

    My apologies on sending the first file. I was hoping to understand the coding you would provide and see if I could alter it my this second file I attached.

    The hide and unhide buttons are very helpful.

  11. #11
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,876

    Re: Hide/Unhide columns in multiple worksheets based on item chosen in a drop down list.

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

  12. #12
    Registered User
    Join Date
    02-26-2014
    Location
    Guelph, Ontario
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Hide/Unhide columns in multiple worksheets based on item chosen in a drop down list.

    Sorry to add to this closed thread. Can you explain the steps to adding the buttons.. i used the developer tab to insert them, and copied your coding into a module 3 in VBA, but I can't seem to get it to work on the file I'm trying to transfer your coding to.

    The steps you took to insert everything would be very helpful.

  13. #13
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,876

    Re: Hide/Unhide columns in multiple worksheets based on item chosen in a drop down list.

    Here is a link to a very short video I made to show you how I made a button and attached code to it.

    https://app.box.com/s/5hjkuiv3fwonomtq1wyf

    Alan

  14. #14
    Registered User
    Join Date
    02-26-2014
    Location
    Guelph, Ontario
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Hide/Unhide columns in multiple worksheets based on item chosen in a drop down list.

    This is perfect. It works! Thanks again alansidman! You were very very helpful.

  15. #15
    Forum Contributor
    Join Date
    10-01-2013
    Location
    Houston
    MS-Off Ver
    Excel 2010
    Posts
    136

    Re: Hide/Unhide columns in multiple worksheets based on item chosen in a drop down list.

    Another option is to rope in alansidman code into a combo box and no need to have buttons to hide or unhide macros…the macros will automatically run when you select that month....attached is an example.
    Attached Files Attached Files

  16. #16
    Registered User
    Join Date
    02-26-2014
    Location
    Guelph, Ontario
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Hide/Unhide columns in multiple worksheets based on item chosen in a drop down list.

    Thanks! This works well too.

+ 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/unhide columns based on dropdown list.
    By bg781np in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-18-2013, 07:13 PM
  2. [SOLVED] hide or unhide rows based on text within a drop down list
    By souimet in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-17-2013, 01:32 AM
  3. Unhide or hide sheets based on drop down list value - need help combining these two macros
    By kstrick99999 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-02-2012, 06:07 PM
  4. [SOLVED] Auto fill line when item is chosen from drop down list.
    By ericabutkovich in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 10-09-2012, 05:47 PM
  5. Hide/unhide columns based on the drop down list value
    By vagif in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-16-2012, 02:13 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