ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Name and number of sheets (https://www.excelbanter.com/excel-discussion-misc-queries/18306-name-number-sheets.html)

MB

Name and number of sheets
 
Could someone please post the code that will count the
number of sheets in a workbook and get each sheet name. I
thought I could use the for statement after I got the
number of sheets, but can't seem to get that number.

Thank you

Dave Peterson

Maybe something like:

Option Explicit
Sub testme()

Dim wks As Worksheet

MsgBox Sheets.Count
MsgBox Worksheets.Count

For Each wks In ActiveWorkbook.Worksheets
MsgBox wks.Name
Next wks
End Sub

Worksheets.count may not equal sheets.count (if you have chart sheets for
example).

MB wrote:

Could someone please post the code that will count the
number of sheets in a workbook and get each sheet name. I
thought I could use the for statement after I got the
number of sheets, but can't seem to get that number.

Thank you


--

Dave Peterson


All times are GMT +1. The time now is 12:20 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com