
Originally Posted by
vakbel
Hello dear friends,
I would like to hide all worksheets except the ones that I've selected (so it is vice-versa for hiding the selected ones).
Not really sure about it tough.
Sub HideOther()
Dim myWs, i As Long, ws As Worksheet, x
With ActiveWindow.SelectedSheets
ReDim myWs(1 To .Count)
For i = 1 To .Count
myWs(i) = .Item(i).Name
Next
End With
For Each ws In Worksheets
x = Application.Match(ws.Name, myWs, 0)
If IsError(x) Then ws.Visible = 0
Next
End Sub
Sub HideSelected()
Dim myWs, i As Long, ws As Worksheet, x
With ActiveWindow.SelectedSheets
ReDim myWs(1 To .Count)
For i = 1 To .Count
myWs(i) = .Item(i).Name
Next
End With
For Each ws In Worksheets
x = Application.Match(ws.Name, myWs, 0)
If IsError(x) Then
ws.Visible = 1
Else
ws.Visible = 0
End If
Next
End Sub
Bookmarks