+ Reply to Thread
Results 1 to 7 of 7

better option for vba code to hide unhide over 80 sheets

  1. #1
    Forum Contributor
    Join Date
    04-02-2019
    Location
    Ottawa,Ontario
    MS-Off Ver
    365
    Posts
    183

    better option for vba code to hide unhide over 80 sheets

    If I have over 80 tabs that I'd like hide/unhide based upon values, is this code valid or is there a better way vs. coding that has an absolutely a ton of lines?

    Please Login or Register  to view this content.
    Ron
    Last edited by davesexcel; 12-15-2023 at 10:10 AM.

  2. #2
    Valued Forum Contributor
    Join Date
    08-31-2007
    Location
    SW Ireland
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2311 Build 16.0.17029.20068) 32-bit
    Posts
    540

    Re: better option for vba code to hide unhide over 80 sheets

    The criteria for showing/hiding seem to depend on different ranges of cells which makes things a bit messier. Someone with more skill than I might suggest constructing some kind of array of ranges which can be checked against individual sheets.

    One easy fix which removes a number of lines from the existing code is:

    Please Login or Register  to view this content.
    In the Range("b6:f6") or Range("g6:h6"), I'd add the sheet codename reference at the start e.g. Sheet1 for clarity.
    Excel 365 user. To unblock a downloaded macro-enabled workbook, go to your "Downloads" folder > right click on the workbook name > click 'Properties' > check the 'Unblock' checkbox. You can now open the workbook.

  3. #3
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,524

    Re: better option for vba code to hide unhide over 80 sheets

    You can loop through the sheets.

    This particular sample will loop through all the sheets but skip the sheet named "Not This Sheet"

    It counts the cells in B6:F6
    Please Login or Register  to view this content.
    Last edited by davesexcel; 12-15-2023 at 10:40 AM.

  4. #4
    Forum Contributor
    Join Date
    04-02-2019
    Location
    Ottawa,Ontario
    MS-Off Ver
    365
    Posts
    183

    Re: better option for vba code to hide unhide over 80 sheets

    I'm sorry, I don't quite understand what is being said.

    I'm adding what I've done so far, but I know there has to be a better way.
    I'm finding that changes are required and I have copied the sheets, but it would be so much easier if I could just change 1 sheet and have the rest make the changes without messing with the formulas and of course somehow reducing the vba coding.

    please don't laugh too hard how inefficent I can be lol.

    Ron
    Attached Files Attached Files

  5. #5
    Valued Forum Contributor
    Join Date
    08-31-2007
    Location
    SW Ireland
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2311 Build 16.0.17029.20068) 32-bit
    Posts
    540

    Re: better option for vba code to hide unhide over 80 sheets

    The following might achieve what you're seeking. I'm assuming that you hide the sheets when the workbook is about to be closed (Q- do you show them when it's opened?)- when you are about to exit the workbook, the macro runs.close

    If you prefer a button on a sheet which you can click to show or hide sheets, let me know.

  6. #6
    Valued Forum Contributor
    Join Date
    08-31-2007
    Location
    SW Ireland
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2311 Build 16.0.17029.20068) 32-bit
    Posts
    540

    Re: better option for vba code to hide unhide over 80 sheets

    EDIT- the attached workbook is an improvement so use this instead.
    Attached Files Attached Files

  7. #7
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,301

    Re: better option for vba code to hide unhide over 80 sheets

    I don't know if it will work, but try it ...
    ?
    Please Login or Register  to view this content.
    ?

+ 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. [SOLVED] Hide Unhide Yellow Sheets Code Error
    By BillySpivy in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 03-16-2022, 02:19 PM
  2. Need VBA code to unhide and hide sheets with a link
    By 504calculator in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 01-31-2022, 02:11 PM
  3. [SOLVED] VB Code .xlsm file with automatically hide and unhide sheet entities option
    By Sekars in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-28-2019, 07:54 AM
  4. [SOLVED] VBA code to hide/unhide rows on 2 different sheets-HELP
    By bugdout in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-13-2017, 04:03 PM
  5. Required macro with button/option to hide unhide several sheets
    By vishpuj in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-25-2015, 06:43 AM
  6. Hide and Unhide sheets based on Date [better code]
    By Deryl in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-30-2012, 09:22 AM
  7. Replies: 2
    Last Post: 04-18-2011, 01:56 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