Really thanks for all your help! :=)
"Ron Rosenfeld" wrote:
On Mon, 17 Jan 2005 09:07:03 -0800, Vincdc
wrote:
Hello:
Is there any function or other method to count the number of worksheets in a
workbook? I have a workbook which includes dozens of worksheets (each for one
client) and I would like to know the total number of clients.
Thanks in advance!
A VBA UDF (User Defined Function) would be best.
It is possible to use a Named formula GET.WORKBOOK(4) but this can cause
problems resulting in Excel crashing under certain circumstances.
If you are only counting Worksheets, as you write, then:
============================
Function SheetCount()
SheetCount = ActiveWorkbook.Worksheets.Count
End Function
============================
However, be aware the Charts are not Worksheets. So if you have Chart sheets
that you wish to include in the count, use:
=========================
Function SheetCount()
SheetCount = ActiveWorkbook.Sheets.Count
End Function
=======================
To enter this UDF, <alt-F11 opens the VB Editor.
Ensure your project is highlighted in the Project Explorer Window, then
Insert/Module and paste the code into the window that opens.
In some cell in the workbook, enter the formula
=SheetCount()
The cell should display the count.
--ron