Results 1 to 4 of 4

Unhide hidden sheets + Scroll all sheets

Threaded View

  1. #3
    Forum Contributor
    Join Date
    04-30-2008
    Posts
    105
    Its a bit longer but it should work. If you don't have a Password for these sheets, just delete that part of the code that says "Password:="Password". Also, the code won't cause the macro to stop partially through the code since when you do delete a sheet, Excel will, by default, ask you whether or not you want to permanently delete that particular sheet.

    Sub UnhideSheetsDemo()
      Dim i As Integer
      Dim n As Integer
        
        i = ActiveWorkbook.Sheets.Count
      
        Application.ScreenUpdating = False
      
        For n = 1 To i
      
        If Sheets(n).Visible = False Then
            Sheets(n).Visible = True
        End If
        
        If Sheets(n).Protect Then
            Sheets(n).Unprotect Password:="Password" 'replace with your actual password
            With Sheets(n).PageSetup
                .Orientation = xlPortrait 'change to landscape if that works better
                .PaperSize = xlPaperLetter
                .FitToPagesWide = 1
                .FitToPagesTall = 1
                .PrintErrors = xlPrintErrorsDisplayed
            End With
            Sheets(n).Protect Password:="Password"
       Else
            With Sheets(n).PageSetup
                .Orientation = xlPortrait 'change to landscape if that works better
                .PaperSize = xlPaperLetter
                .FitToPagesWide = 1
                .FitToPagesTall = 1
                .PrintErrors = xlPrintErrorsDisplayed
            End With
    
        End If
        
        Next n
        
        Application.DisplayAlerts = False
        
        On Error Resume Next 'in case any of these files aren't protected and/or actually in the workbook to delete
        If Sheets("Temp1").Protect Then
            Sheets("Temp1").Unprotect Password:="Password"
            Sheets("Temp1").Delete
        Else
            Sheets("Temp1").Delete
        End If
        
        If Sheets("work1").Protect Then
            Sheets("work1").Unprotect Password:="Password"
            Sheets("work1").Delete
        Else
            Sheets("work1").Delete
        End If
        
        If Sheets("work3").Protect Then
            Sheets("work3").Unprotect Password:="Password"
            Sheets("work3").Delete
        Else
            Sheets("work3").Delete
        End If
        
        If Sheets("payplan").Protect Then
            Sheets("payplan").Unprotect Password:="Password"
            Sheets("payplan").Delete
        Else
            Sheets("payplan").Delete
        End If
            
        If Sheets("capture").Protect Then
            Sheets("capture").Unprotect Password:="Password"
            Sheets("capture").Delete
        Else
            Sheets("capture").Delete
        End If
        
        If Sheets("Extra (delimited)").Protect Then
            Sheets("Extra (delimited)").Unprotect Password:="Password"
            Sheets("Extra (delimited)").Delete
        Else
            Sheets("Extra (delimited)").Delete
        End If
        
        If Sheets("Temporary (Last month)").Protect Then
            Sheets("Temporary (Last month)").Unprotect Password:="Password"
            Sheets("Temporary (Last month)").Delete
        Else
            Sheets("Temporary (Last month)").Delete
        End If
        
        On Error GoTo 0
        
        Application.DisplayAlerts = True
        
        Application.ScreenUpdating = True
       
    End Sub
    Hope this helps.
    Last edited by fecurtis; 05-21-2008 at 05:42 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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