+ Reply to Thread
Results 1 to 3 of 3

Help with VBA Unhide Code to show specific Worksheets.

Hybrid View

Ortz Help with VBA Unhide Code to... 05-05-2016, 04:51 PM
mikeTRON Re: Help with VBA Unhide Code... 05-05-2016, 05:03 PM
Ortz Re: Help with VBA Unhide Code... 05-05-2016, 05:40 PM
  1. #1
    Registered User
    Join Date
    09-15-2011
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    82

    Help with VBA Unhide Code to show specific Worksheets.

    Hi All

    I have some VBA Code I used from another thread some time ago to Unhide all sheets in a Workbook that were hidden. It worked fantastic for what was needed then.

    This is the Code I used:

    Private Sub CommandButton2_Click()
    Dim ws As Worksheet
     '
         For Each ws In ActiveWorkbook.Worksheets
            
            ws.Visible = xlSheetVisible
    
        Next ws
    
    End Sub
    However the problem is this Unhide's all sheets hidden in the Workbook but I now need it to keep Sheet MI hidden but unhide sheets LSN 1 to 4. Sheet MI is password protected with password Info.

    Is anyone able to help with the Code so it Unhides all sheets except sheet MI.

    I have attached a sample of what I need to use.

    Thanks for any help in advance

    Ortz
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    10-09-2012
    Location
    Dallas, Texas
    MS-Off Ver
    MO 2010 & 2013
    Posts
    3,049

    Re: Help with VBA Unhide Code to show specific Worksheets.

    So first off, if anyone knows anything about Excel they can open the code and SEE the password in INFO, so you might want to also put a password on the code itself, which is a bit annoying but useful. At the end of the day a guru can likely get into anything locked or not.

    Now for your question it is a rather simple request.

    Private Sub CommandButton2_Click()
    Dim ws As Worksheet
    '
        For Each ws In ActiveWorkbook.Worksheets
            If UCase(ws.Name) <> "MI" Then ws.Visible = xlSheetVisible
        Next ws
    
    End Sub
    It means if the worksheet name is NOT "MI" then make the sheet visible.
    You don't HAVE to make it uppercase using UCASE but I find it less likely to cause problems in the future and it is easy enough to throw in.
    Please ensure you mark your thread as Solved once it is. Click here to see how.
    If a post helps, please don't forget to add to our reputation by clicking the star icon in the bottom left-hand corner of a post.

  3. #3
    Registered User
    Join Date
    09-15-2011
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    82

    Re: Help with VBA Unhide Code to show specific Worksheets.

    Thanks mikeTRON

    That works beautifully, exactly what I needed.

    What code would I need to hide them all again with a Command Button ? Sorry for an extra request but the code I have only closes the sheets when the Workbook is closed, is there something else that I could add to a Command Button while the workbook is open to hide the sheets ?

+ 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. VBA code to hide/unhide worksheets
    By holli in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-26-2015, 11:34 AM
  2. VBA Code to Unhide multiple WorkSheets
    By craig159753 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-07-2015, 05:23 AM
  3. [SOLVED] Specific macro or VBA code to hide and unhide rows
    By louvaek in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 11-17-2014, 07:36 AM
  4. Help with VBA Code (Hide/Unhide Worksheets)
    By maryren in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-21-2014, 12:43 PM
  5. Need macro to check values and hide/unhide specific worksheets
    By amsnss in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-29-2011, 01:53 PM
  6. How to unhide specific worksheets in excel using Macros
    By Amateur1001 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-01-2010, 05:21 PM
  7. How to unhide specific worksheets in excel using Macros
    By Amateur1001 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-27-2010, 05:26 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