Requirement:
Is there a piece of VBA the user can use that will count the number of worksheets within a workbook. So this value can then be stored as a variable.
Solution:
Try the following:
Sub CountMe() MsgBox ThisWorkbook.Sheets.Count & " sheets available" End Sub
or to place the value in A1
Sub CountMe() Range("A1").Value = ThisWorkbook.Sheets.Count End Sub
Obtained from the OzGrid Help Forum.
Solution provided by xlite.
See also: Index to Excel VBA Code and Index to Excel Freebies and Lesson 1 - Excel Fundamentals and Index to how to… providing a range of solutions and Index to new resources and reference sheets
See also:
How to count times between 2 specified times |
How to use VBA script to count files/subfolders using a range from WB for the root folder |
How to VBA code to count duplicates FAST |
How to set a countdown timer to beep under 10 seconds |
How to count the number of cells containing a comment that contains the word LATE |
Click here to visit our Free 24/7 Excel/VBA Help Forum where there are thousands of posts you can get information from, or you can join the Forum and post your own questions.