+ Reply to Thread
Results 1 to 2 of 2

Hide all sheets but selected sheets - an example

  1. #1
    aztecbrainsurgeon@yahoo.com
    Guest

    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. #2
    Tom Ogilvy
    Guest

    RE: 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


    "aztecbrainsurgeon@yahoo.com" 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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1