ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Number of Worksheets in a Workbook (https://www.excelbanter.com/excel-programming/395808-number-worksheets-workbook.html)

Dawn

Number of Worksheets in a Workbook
 
Is there a way to write a function that will return the worksheet count to
the user on demand? I know worksheets.count will return the number in VBA -
but how do I make it a function to show the number when needed by the user?

Bob Phillips

Number of Worksheets in a Workbook
 
Write a UDF


Function NumSheets()
NumSheets = Worksheets.Count
End Function

and use that


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Dawn" wrote in message
...
Is there a way to write a function that will return the worksheet count to
the user on demand? I know worksheets.count will return the number in
VBA -
but how do I make it a function to show the number when needed by the
user?




Michael

Number of Worksheets in a Workbook
 
Attach it to a button then button will the do the following

p=Worksheets.Count

Msgbox(p)


--
If this posting was helpful, please click on the Yes button.
Regards,

Michael Arch.




"Dawn" wrote:

Is there a way to write a function that will return the worksheet count to
the user on demand? I know worksheets.count will return the number in VBA -
but how do I make it a function to show the number when needed by the user?


joel

Number of Worksheets in a Workbook
 
call with =numbersheets()

Function numbersheets()

numbersheets = Worksheets.Count
End Function

I would recommend the info function but instead of returning 3 worksheets,
it is returning 6. I not going to tell you to use something that gives a
wrong answer.
=INFO("numfile")




"Dawn" wrote:

Is there a way to write a function that will return the worksheet count to
the user on demand? I know worksheets.count will return the number in VBA -
but how do I make it a function to show the number when needed by the user?



All times are GMT +1. The time now is 06:20 AM.

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