Count sheets in workbook

S

SS

Is there a way to count the sheets in a workbook without doing it manually?

Cheers
Shona
 
R

Rowan

This macro should do it:

Sub shtcount()
MsgBox "# of sheets: " & Sheets.Count
End Sub

Regards
Rowan
 
P

Paul B

Shona, here is one way,

Sub Count_WorkSheets()
Dim c As Integer
c = ActiveWorkbook.Sheets.Count
MsgBox "There are " & c & " Sheet(s)"
End Sub

If you are new to Macros have a look here on getting started with macros
http://www.mvps.org/dmcritchie/excel/getstarted.htm


--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003
 
Top