VBA- Counting the number of the sheets

  • Thread starter Thread starter Timse
  • Start date Start date
T

Timse

Hi,

I’m trying to write a macro which could count the number of the sheet
in the workbook. I need this for a condition in my do-loop circle. Th
number of the sheets is variable.

If somebody could help me and tell me a way to do this I would be ver
pleased.


Thanks,

-Tims
 
Timse,

these two should do the job:

Activeworkbook.Sheets.Count

OR

Workbooks("name").Sheets.Count

Good luc
 
Timse,

Worksheets.Count will return the number.

HTH,
Nikos
 
Timse

ActiveWorkbook.Sheets.Count

will count all the sheets (worksheets, charts, etc.)

ActiveWorkbook.Worksheets.Count

just the worksheets.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top