Hi, VDS!
There's a formula only solution that has certain constraints but maybe it helps here. The INFO function.
The INFO function used with the argument "NUMFILE" retrieves the number of active worksheets, but for all the opened workbooks in the actual Excel running instance, that's to say, it includes all worksheets from your add-ins and other workbooks.
There're 2 workarounds:
a) If you always have the same workbooks opened, and just vary the new one for which you want to know how many worksheets does it has, do this:
Once.
- open a new Excel instance with the usual workbooks
- create a new file
- in A1 of 1st sheet type this:
=INFO("numfile")
- keep the displayed value minus the no. of worksheets of the new file (usually 3) as the "other worksheets"
Every time you open a new workbook.
- place the same INFO function in any empty cell
- subtract the "other worksheets" number from the retrieved value, that'd be the no. of worksheets of the opened file.
b) If you constantly vary the number of workbooks, do this:
- place the info formula in any empty cell of a yet opened workbook
- open the new workbook
- place the info formula in any empty cell of the new workbook
- subtract both values, that'd be the no. of worksheets of the opened file.
Hope it helps. But if you ask me for an advice, use the UDF at the start of this thread.
Regards!