Counting sheets in a workbook.

  • Thread starter Thread starter Danny
  • Start date Start date
Try this macro:

Sub Count_WS()
Dim a As Integer
a = ActiveWorkbook.Worksheets.Count
MsgBox a & " worksheets"
End Sub
 
And just in case you want to count chart sheets as well, with a slight tweak on Jason's code:-

Sub Count_WS()

Dim a As Integer
a = ActiveWorkbook.Worksheets.Count
b = ActiveWorkbook.Charts.Count
MsgBox a & " Worksheets, " & b & " Chart Sheets"

End Sub

or if you wanted it all lumped together, including any chart sheets

Sub Count_WS()
Dim a As Integer
a = ActiveWorkbook.Sheets.Count
MsgBox a & " Sheets"

End Sub
 
Ken,
This macro helps me a lot too! I was "manually" counting
my chart sheets. Thanks a lot!
Danny
-----Original Message-----
And just in case you want to count chart sheets as well,
with a slight tweak on Jason's code:-
 
Back
Top