Sub SheetInfo()
Dim Sh As Object
Dim WS As Worksheet
Dim S As String, V As String, MyTabs As String
MsgBox "This macro displays sheet information in the VBE 'Immediate' window.", vbOKOnly Or vbInformation, "Workbook '" & ActiveWorkbook.Name & "'"
S = S & "Sheet Information (Workbook '" & ActiveWorkbook.Name & "')" & vbNewLine
S = S & ActiveWorkbook.Sheets.Count & " sheets found." & vbNewLine
S = S & "---------------------------------------" & vbNewLine
For Each Sh In ActiveWorkbook.Sheets
S = S & Sh.CodeName & " (" & Sh.Name & ")"
If Len(Sh.CodeName & " (" & Sh.Name & ")") > 16 Then
MyTabs = VBA.String(1, vbTab)
Else
MyTabs = VBA.String(2, vbTab)
End If
S = S & MyTabs & "Type: " & TypeName(Sh)
S = S & ", Protected: " & CStr(Sh.ProtectContents = True)
Select Case Sh.Visible
Case -1
V = "xlSheetVisible"
Case 0
V = "xlSheetHidden"
Case 2
V = "xlSheetVeryHidden"
Case Else
V = "?"
End Select
S = S & ", Visbility: " & V & vbNewLine
Next Sh
Debug.Print S
End Sub