Make all sheets visible except one

ndendrinos

Well-known Member
Joined
Jan 17, 2003
Messages
1,694
Trying to edit code to make all sheets visible EXCEPT sheet "Log"

Here is the code:
Code:
Private Sub Workbook_Open()
Application.ScreenUpdating = False

      Dim Sheet As Worksheet
      'make all sheets visible
      For Each Sheet In Worksheets
            If Sheet.Name <> "Prompt" Then
                  Sheet.Visible = xlSheetVisible
                  
            End If
      Next Sheet
      'hide the prompt and go to A1 on sheet1
      Sheets("Prompt").Visible = xlSheetVeryHidden
      Application.Goto Sheet1.[A1], scroll:=True
      'clean up
      Set Sheet = Nothing
      ActiveWorkbook.Saved = True
      Application.ScreenUpdating = True

End Sub
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Hi,

This should do it:

Code:
Private Sub Workbook_Open()

Dim Sheet As Worksheet

Application.ScreenUpdating = False
    
'make all sheets visible

For Each Sheet In Worksheets
    
    If Sheet.Name <> "Log" Then

        Sheet.Visible = xlSheetVisible
                  
    End If

Next Sheet
      
'hide the prompt and go to A1 on sheet1

Sheets("Log").Visible = xlSheetVeryHidden
      
'clean up
      
Set Sheet = Nothing

ActiveWorkbook.Saved = True

Application.ScreenUpdating = True

End Sub
 
Upvote 0
Hello Domski
Tried your edit and it sure hides sheet "Log" BUT now the sheet "Prompt" stays visible.
Fixed it with:

Code:
Next Sheet
     
'hide the prompt and go to A1 on sheet1

Sheets("Prompt").Visible = xlSheetVeryHidden
     
'clean up
     
Set Sheet = Nothing

ActiveWorkbook.Saved = True

Application.ScreenUpdating = True
End Sub
 
Upvote 0
Trying to edit code to make all sheets visible EXCEPT sheet "Log"

You really mean you want all sheets visible EXCEPT sheet "Log" and "Prompt" then?

Dom
 
Upvote 0
Correct, sorry I should have been more precise.
Thank you very much for your help.
BTW you've answered a post about keeping tab on who edits a file.
I have posted my answer too and maybe you will like to have a look
Best regards and thanks again
 
Upvote 0
Hi,

No worries.

This might be better:

Code:
Private Sub Workbook_Open() 

Application.ScreenUpdating = False

Dim Sheet As Worksheet
      
'make all sheets visible

For Each Sheet In Worksheets
    
    If Sheet.Name <> "Log" Or Sheet.Name <> "Prompt" Then

        Sheet.Visible = xlSheetVisible
                  
    End If

Next Sheet
      
'hide the log and prompt sheets

Sheets("Log").Visible = xlSheetVeryHidden
Sheets("Prompt").Visible = xlSheetVeryHidden
      
'clean up
      
Set Sheet = Nothing

ActiveWorkbook.Saved = True

Application.ScreenUpdating = True

End Sub

Had a quick look at other post. The idea sounds fine although not tested the code. It all depends on the workbook being saved and the person enabling macros when the file is open which can both be easily avoided though. I think the OP is interested in who has already been using a file rather than a future project as well, but i could be wrong.

Dom
 
Upvote 0

Forum statistics

Threads
1,214,400
Messages
6,119,284
Members
448,885
Latest member
LokiSonic

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top