MyriamSL
10-25-2023, 06:50 AM
Hi,
I have the following script in "ThisWorkbook", because I need these actions to be performed on opening.
Private Sub Ouverture()
Sheets("Gestion").Activate
Dim ws As Worksheet
Dim gestion As String
gestion = ActiveSheet.Name
For Each ws In ActiveWorkbook.Worksheets
If ws.Name <> gestion Then
ws.Visible = xlSheetHidden
End If
Next ws
End Sub
I know the code works because if I put it in a module and run it, it works perfectly fine. It just doesn't work the way I want it to (on opening). What am I missing here? I feel like this should be pretty simple...
Thanks!
I have the following script in "ThisWorkbook", because I need these actions to be performed on opening.
Private Sub Ouverture()
Sheets("Gestion").Activate
Dim ws As Worksheet
Dim gestion As String
gestion = ActiveSheet.Name
For Each ws In ActiveWorkbook.Worksheets
If ws.Name <> gestion Then
ws.Visible = xlSheetHidden
End If
Next ws
End Sub
I know the code works because if I put it in a module and run it, it works perfectly fine. It just doesn't work the way I want it to (on opening). What am I missing here? I feel like this should be pretty simple...
Thanks!