Get list worksheet names for only visible worksheets in a workbook

J

Juluka

Please could somebody help me with my query:

I am trying to get a list of worksheet names for only the visibl
worksheets in an open workbook
 
R

Robert Rosenberg

The following macro lists the visible sheets of the active workbook in a
message box:

Sub VisibleSheets()

Dim sht As Object
Dim szList As String

For Each sht In ActiveWorkbook.Sheets
If sht.Visible = xlSheetVisible Then szList = szList & vbLf &
sht.Name
Next sht

szList = "The following sheets are visible in " & ActiveWorkbook.Name &
":" & vbLf & szList
MsgBox szList, vbInformation, "Visible Sheets"
End Sub
 
Top