How to count Worksheets in Excel file ?
hello everyone,
I have created many Worksheets in my Excel and I'm totally unaware how many are actually there. I usually create the new ones and add them to my excel file without deleting the old and unwanted ones. I want to count the actual number os worksheets in my excel files ? Can anybody help me how can I do this ?
any ideas.....
Re: How to count Worksheets in Excel file ?
To find the count of the number of worksheets, you can use this -
Code:
NoSheets = ActiveWorkbook.Worksheets.Count
Re: How to count Worksheets in Excel file ?
Go to the code in "ThisWorkBook". You can find the code by
>> pressing ALT+F11
>> Right-clicking on "ThisWorkBook" on the left
>> Left clicking on view code.
Then paste in the following
Private Sub Workbook_Open()
Sheets("NameOfSheet").Cells(1, 1).Value = Worksheets.Count
End Sub
When the worksheet opens, it'll count the number of worksheets and put the
value in a specified cell. So in this case if you had a sheet named
NameOfSheet it would put a number in Row 1, Column A.