Tuesday, June 16, 2020

PrintOut Only Hidden Worksheets

Sub PrintOutOnlyHiddenWorksheets()

'NOTE: xlSheetVisible = -1, xlSheetHidden = 0, xlSheetVeryHidden = 2
    Dim visibleState As Long
    Dim sh As Worksheet
   
    For Each sh In ActiveWorkbook.Worksheets
        With sh
            ''store old state
            visibleState = .Visible
            If visibleState >= 0 Then
            ''change visible state
                .Visible = -1
                .PrintOut
                ''restore old state
                .Visible = visibleState
            End If
        End With
    Next
   
End Sub

No comments:

Post a Comment

Hot Topics