I am trying to make a workbook that will group diffrent types of sheets such as P&L's, Site information and Vehicles. Excel file enclosed.
I have used this code which works:
Private Sub Worksheet_Activate()
Dim sh As Worksheet 'Object
Dim arr As Variant
arr = Array("Facility 1 P&L", "Facility 2 P&L", "Facility 3 P&L") '
On Error GoTo XIT
With Application
.EnableEvents = False
.ScreenUpdating = False
End With
For Each sh In ThisWorkbook.Sheets
If Not sh.Name Like "Master*" Then
sh.Visible = xlSheetHidden
End If
Next sh
For Each sh In Sheets(arr)
sh.Visible = xlSheetVisible
Next sh
XIT:
With Application
.EnableEvents = True
.ScreenUpdating = True
End With
End Sub
Private Sub Worksheet_Deactivate()
Dim sh As Worksheet
Dim arr As Variant
arr = Array("Facility 1 P&L", "Facility 2 P&L", "Facility 3 P&L") '
On Error GoTo XIT
With Application
.EnableEvents = False
.ScreenUpdating = False
End With
For Each sh In Sheets(arr)
sh.Visible = xlSheetVisible
Next sh
XIT:
With Application
.EnableEvents = True
.ScreenUpdating = True
End With
End Sub
Now the problem that I have is although I can rename the array sheets and get them to hide, the sheets Master1, Master2 and Master3 would be better named P&L, Site Info and Vehicles.
I assume this function controls the display of the master sheets so they are always on view:
For Each sh In ThisWorkbook.Sheets
If Not sh.Name Like "Master*" Then
sh.Visible = xlSheetHidden
End If
Next sh
Is there a way to change the master* to use the three above. Every time I try and change one the sheet disappears.
Thanks
Bookmarks