Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default 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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to repeat a code for selected sheets (or a contiguous range of sheets) in a Workbook? Dmitry Excel Worksheet Functions 6 March 29th 06 12:43 PM
How to repeat a code for selected sheets (or a contiguous range of sheets) in a Workbook? Dmitry Excel Programming 6 March 29th 06 12:43 PM
How to tell if multiple sheets are selected? Mike Weaver Excel Programming 4 February 7th 06 08:12 PM
Selected Sheets Glen Mettler[_4_] Excel Programming 6 February 21st 05 09:25 PM
Moving selected sheets Primoz Bradac Excel Programming 2 September 24th 03 11:41 AM


All times are GMT +1. The time now is 01:33 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"