Public Function SheetCount(intCommand As Variant) As Integer ' This function will return a count of the number of sheets within the workbook ' It can return a count of hidden, very hidden, visible or total worksheets ' If the value passed is invalid it will default to count all sheets ' The passed parameter can be either an integer or a string. ' The following are valid parameters ' -1 or "Visible" to count visible sheets ' 0 or "Hidden" to count hidden sheets ' 2 or "VeryHidden" to count very hidden sheets ' Any value or "Total" to count the total number of sheets ' Copyright Abbydale Systems LLC. Dim v As Integer Dim conv As Integer If Not IsNumeric(intCommand) Then intCommand = UCase(intCommand) Select Case intCommand Case "HIDDEN" conv = 0 Case "VISIBLE" conv = -1 Case "VERYHIDDEN" conv = 2 Case Else intCommand = "TOTAL" End Select Else intCommand = Int(intCommand) If intCommand > 2 Or intCommand < -1 Or intCommand = 1 Then intCommand = "TOTAL" Else conv = intCommand End If End If If intCommand = "TOTAL" Then SheetCount = ActiveWorkbook.Sheets.Count Else v = 0 For Each s In ActiveWorkbook.Sheets If (s.Visible = conv) Then v = v + 1 Next s SheetCount = v End If End Function