+ Reply to Thread
Results 1 to 10 of 10

Hide Unhide Yellow Sheets Code Error

  1. #1
    Banned User!
    Join Date
    06-18-2021
    Location
    Peru
    MS-Off Ver
    2010, Microsoft 365
    Posts
    431

    Hide Unhide Yellow Sheets Code Error

    Hello,

    On the Monthly Budget sheet there are purple shapes labeled "H" and "U" which are supposed to hide the sheets with tab color yellow or unhide them. These are not working now and I don't know why.

    Can someone please see how to fix?

    Thank you very much

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Hide Unhide Yellow Sheets Code Error

    In the Ribbon 'Review' Menu the Workbook is showing as protected. Click the 'Protect Workbook' icon to unprotect.

    As for the macro I generally find it's not a good idea to have code that is dependent on the colour of something. Personally I'd use the ws.Name i.e. "Transactions" in the If test.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Banned User!
    Join Date
    06-18-2021
    Location
    Peru
    MS-Off Ver
    2010, Microsoft 365
    Posts
    431

    Re: Hide Unhide Yellow Sheets Code Error

    Can unprotect be added to the codes in some way then reprotect?

  4. #4
    Banned User!
    Join Date
    06-18-2021
    Location
    Peru
    MS-Off Ver
    2010, Microsoft 365
    Posts
    431

    Re: Hide Unhide Yellow Sheets Code Error

    I added these to the codes and it seemed to work thanks.

    Thisworkbook.Unprotect
    Thisworkbook.Protect

  5. #5
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Hide Unhide Yellow Sheets Code Error

    Top and tail your Hide_Yellow_SHeets macro with

    ActiveWorkbook.Protect Structure:=False, Windows:=False

    ActiveWorkbook.Protect Structure:=True, Windows:=False

    Incidentally using the Tab.Color code isn't actually doing anything. As I said you'd be better advised to test the tab name or some other unique characteristic.

    Incidentally the ws.Visible = xlSheetHidden instruction is processed every time the ws.Name changes.
    There's no reason to have a loop at all. You might just as well hide the sheet directly as the one and only instruction,

  6. #6
    Banned User!
    Join Date
    06-18-2021
    Location
    Peru
    MS-Off Ver
    2010, Microsoft 365
    Posts
    431

    Re: Hide Unhide Yellow Sheets Code Error

    I appreciate the advice but I frequently need to unhide the group of sheets then hide them again. If I have to do this for each sheet it is too time consuming.

    Have a great day!

  7. #7
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Hide Unhide Yellow Sheets Code Error

    Quote Originally Posted by BillySpivy View Post
    I appreciate the advice but I frequently need to unhide the group of sheets then hide them again. If I have to do this for each sheet it is too time consuming.

    Have a great day!
    I don't understand your comment. It's the macro that does the hiding & unhiding. Where did I ever suggest you needed to do this for each sheet - presumably you mean manually.

  8. #8
    Banned User!
    Join Date
    06-18-2021
    Location
    Peru
    MS-Off Ver
    2010, Microsoft 365
    Posts
    431
    Quote Originally Posted by Richard Buttrey View Post
    I don't understand your comment. It's the macro that does the hiding & unhiding. Where did I ever suggest you needed to do this for each sheet - presumably you mean manually.
    I appreciate your help and advice but I choose to find another solution. I mean no offense and hope you understand that I prefer another way.

  9. #9
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Hide Unhide Yellow Sheets Code Error

    Quote Originally Posted by BillySpivy View Post
    I appreciate your help and advice but I choose to find another solution. I mean no offense and hope you understand that I prefer another way.
    I'm not questioning that. There are often many solutions to the same question. Choose whichever you prefer.

    I was asking why you think I was suggesting something that didn't meet your requirement and by implication not operating with all sheets. The Workbook Structure Protect/Unprotect in this context achieves your aim as does the Sheet protect/unprotect.

  10. #10
    Banned User!
    Join Date
    06-18-2021
    Location
    Peru
    MS-Off Ver
    2010, Microsoft 365
    Posts
    431

    Re: Hide Unhide Yellow Sheets Code Error

    I hope you consider removing my posts so others have room for theirs.

+ 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. 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
  2. [SOLVED] VBA code to hide/unhide several sheets based on one cell reference
    By Absalon in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-08-2020, 07:59 AM
  3. [SOLVED] Hide/Unhide Scroll Bars Code for Specific Sheets
    By crazyforexcel in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-21-2019, 09:28 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. [SOLVED] Unexplainable Run-time error 1004 from hide/unhide rows code
    By L plates in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-20-2015, 04:26 AM
  6. [SOLVED] VBA code to hide/unhide sheets based on a tick-box (TRUE/FALSE)
    By kavindra in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-10-2013, 08:11 AM
  7. 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

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