ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Counting the number of Worksheets in a Workbook (https://www.excelbanter.com/excel-worksheet-functions/114183-counting-number-worksheets-workbook.html)

Bill from Holland Michigan

Counting the number of Worksheets in a Workbook
 
I want to show how many sheets I have in a workbook using a formula. The
number changes everyday. What do I use, or can I even do this?

Gary L Brown

Counting the number of Worksheets in a Workbook
 
This user defined function will do it...

Public Function WksCount() As Integer
WksCount = Application.Worksheets.Count
End Function

HTH,
--
Gary Brown

If this post was helpful, please click the ''Yes'' button next to ''Was this
Post Helpfull to you?''.


"Bill from Holland Michigan" wrote:

I want to show how many sheets I have in a workbook using a formula. The
number changes everyday. What do I use, or can I even do this?


Ken Johnson

Counting the number of Worksheets in a Workbook
 
Gary L Brown wrote:
This user defined function will do it...

Public Function WksCount() As Integer
WksCount = Application.Worksheets.Count
End Function

HTH,
--
Gary Brown


If any of your sheets are not worksheets (eg chart sheets, xl4macro
sheets) then you should use...

Public Function ShtCount() As Integer
ShtCount = Application.Sheets.Count
End Function

Ken Johnson



All times are GMT +1. The time now is 07:25 PM.

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