![]() |
Hide all sheets but selected sheets - an example
No question here, just a procedure example for the archive.
Hide all worksheets in the active workbook but the selected sheets Credit to original poster (Bob Phillips) for code Sub HideAllSheetsBUTSELECTEDSheets() 'Hides all worksheets in the active workbook except the 'selected worksheets Dim sh As Worksheet Dim fFound As Boolean Dim groupedArr() As Variant Dim i As Long ReDim groupedArr(1 To ActiveWindow.SelectedSheets.Count) For i = LBound(groupedArr) To UBound(groupedArr) groupedArr(i) = ActiveWindow.SelectedSheets(i).Name Next Application.DisplayAlerts = False For Each sh In ActiveWorkbook.Worksheets fFound = False For i = LBound(groupedArr) To UBound(groupedArr) If sh.Name = groupedArr(i) Then fFound = True Exit For End If Next i ' If Not fFound Then sh.Delete ' use this row for deletes If Not fFound Then sh.Visible = xlSheetHidden Next Application.DisplayAlerts = True End Sub Search criteria hide all sheets but selected hide ungrouped sheets show only grouped sheets Compare worksheet groups compare sheet groups |
Hide all sheets but selected sheets - an example
Credit to original poster (Bob Phillips) for code
So why are you posting it? -- Regards, Tom Ogilvy " wrote: No question here, just a procedure example for the archive. Hide all worksheets in the active workbook but the selected sheets Credit to original poster (Bob Phillips) for code Sub HideAllSheetsBUTSELECTEDSheets() 'Hides all worksheets in the active workbook except the 'selected worksheets Dim sh As Worksheet Dim fFound As Boolean Dim groupedArr() As Variant Dim i As Long ReDim groupedArr(1 To ActiveWindow.SelectedSheets.Count) For i = LBound(groupedArr) To UBound(groupedArr) groupedArr(i) = ActiveWindow.SelectedSheets(i).Name Next Application.DisplayAlerts = False For Each sh In ActiveWorkbook.Worksheets fFound = False For i = LBound(groupedArr) To UBound(groupedArr) If sh.Name = groupedArr(i) Then fFound = True Exit For End If Next i ' If Not fFound Then sh.Delete ' use this row for deletes If Not fFound Then sh.Visible = xlSheetHidden Next Application.DisplayAlerts = True End Sub Search criteria hide all sheets but selected hide ungrouped sheets show only grouped sheets Compare worksheet groups compare sheet groups |
All times are GMT +1. The time now is 06:57 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com