Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How to repeat a code for selected sheets (or a contiguous range of sheets) in a Workbook? | Excel Worksheet Functions | |||
How to repeat a code for selected sheets (or a contiguous range of sheets) in a Workbook? | Excel Programming | |||
How to tell if multiple sheets are selected? | Excel Programming | |||
Selected Sheets | Excel Programming | |||
Moving selected sheets | Excel Programming |