waynerenaud
IS-IT--Management
Using the code directly from vba help in excel but changing true to false
For Each sh In Sheets
sh.Visible = False
Next sh
causes runtime error 1004
I am assuming that this is because you cannot set all sheets to hidden (please someone confirm if this is the case)
What I want to do is open a workbook that opens a userform. I only want the userform to show so am trying to hide the worksheets (this is purely for asthetics) then set them back to visible = true on closing the userform.
Private Sub Workbook_Open()
For Each sh In Sheets
sh.Visible = False
Next sh
userform1.Show
End Sub
'CommandButton3 is the button used to close the userform
Private Sub CommandButton3_Click()
Unload UserForm1
For Each sh In Sheets
sh.Visible = True
Next sh
End Sub
How can I make this work. Thanks
For Each sh In Sheets
sh.Visible = False
Next sh
causes runtime error 1004
I am assuming that this is because you cannot set all sheets to hidden (please someone confirm if this is the case)
What I want to do is open a workbook that opens a userform. I only want the userform to show so am trying to hide the worksheets (this is purely for asthetics) then set them back to visible = true on closing the userform.
Private Sub Workbook_Open()
For Each sh In Sheets
sh.Visible = False
Next sh
userform1.Show
End Sub
'CommandButton3 is the button used to close the userform
Private Sub CommandButton3_Click()
Unload UserForm1
For Each sh In Sheets
sh.Visible = True
Next sh
End Sub
How can I make this work. Thanks