Returns the number of sheets
You can use the built-in worksheet function SHEETS in Excel 2013 to return the number of sheets in the active workbook.


* For instructions on how to add a function to a workbook refer to the page under Inserting Functions

Public Function COUNTSHEETS( _ 
Optional ByVal bIncludeChartSheets As Boolean = True) As Integer

   If bIncludeChartSheets = True Then
      COUNTSHEETS = Application.ActiveWorkbook.Sheets.Count
      COUNTSHEETS = Application.ActiveWorkbook.Worksheets.Count
   End If

End Function


In Power Utility Pack this function is called SHEETCOUNT

© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext