question

EinarOseiSies-4413 avatar image
0 Votes"
EinarOseiSies-4413 asked EinarOseiSies-4413 commented

Macro do not hide sheets

Please I have wanted to hide some sheets in my workbook. Please this the code:-
Sub sbHideSheets()

     On Error Resume Next                        'Prevent errors showing - will simply keep going
       
     shtSplash.Visible = xlSheetVisible          'Make splash screen visible
    
     For Each oSheet In ActiveWorkbook.Sheets    'Loop through all worksheets in the active workbook
    
        
         If oSheet.Name <> shtSplash.Name Then oSheet.Visible = xlSheetVeryHidden   'If not splash screen then make very hidden
            
     Next oSheet
 'BECAUSE IT DIDN'T HIDE I TRIED TO RUN IT IN A DIFFERENT WAY
 Sheets("WARN").Visible = True
 Sheets("PEN 1").Visible = xlVeryHidden
 Sheets("PEN 2").Visible = xlVeryHidden
 Sheets("PEN 3").Visible = xlVeryHidden
 Sheets("PEN 4").Visible = xlVeryHidden
 Sheets("PEN 5").Visible = xlVeryHidden
 Sheets("ISOLATION").Visible = xlVeryHidden
 Sheets("1Audit").Visible = xlVeryHidden
 Sheets("OVERALL TOTAL DETAILS").Visible = xlVeryHidden
 Sheets("OVERALL TOTAL").Visible = xlVeryHidden
 Sheets("HOME").Visible = xlVeryHidden
    
     On Error GoTo 0                             'Reset error handler to default setting
    
 End Sub

Please info behind this workbook is that it has sheet that are protected. Any help!
Einar

office-vba-dev
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

TvanStiphout avatar image
0 Votes"
TvanStiphout answered EinarOseiSies-4413 commented

Comment out the first line
On Error Resume Next

When something is not working, the LAST thing you want is to ignore errors.

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks it works

0 Votes 0 ·