Number of Worksheets in a Workbook

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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?
 
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)
 
Attach it to a button then button will the do the following

p=Worksheets.Count

Msgbox(p)
 
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")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top