#1   Report Post  
Posted to microsoft.public.excel.misc
Jo Jo is offline
external usenet poster
 
Posts: 113
Default count worksheets

can you tell how many worksheets are in your workbook without physically
counting them? I have renamed my sheets so they're not consecutively
numbered any more.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default count worksheets

Sub sheets_num()
MsgBox ActiveWorkbook.Sheets.Count & " sheets in workbook"
End Sub


Gord Dibben MS Excel MVP


On Wed, 12 Dec 2007 16:26:00 -0800, Jo wrote:

can you tell how many worksheets are in your workbook without physically
counting them? I have renamed my sheets so they're not consecutively
numbered any more.


  #3   Report Post  
Posted to microsoft.public.excel.misc
Jo Jo is offline
external usenet poster
 
Posts: 113
Default count worksheets


Thanks Gord Dibben, but I'm not sure if this is a function or something
available in the menus....more information please

"Gord Dibben" wrote:

Sub sheets_num()
MsgBox ActiveWorkbook.Sheets.Count & " sheets in workbook"
End Sub


Gord Dibben MS Excel MVP


On Wed, 12 Dec 2007 16:26:00 -0800, Jo wrote:

can you tell how many worksheets are in your workbook without physically
counting them? I have renamed my sheets so they're not consecutively
numbered any more.



  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9
Default count worksheets

Gord is showing you a VBA subroutine that will do the trick. I'm not
aware of a built in Excel function that will answer this question for
you without the use of VBA. The following link might be helpful to
you, if you want to learn about creating user-defined functions, which
is what appears to be necessary.

http://www.vertex42.com/ExcelArticle...functions.html

  #5   Report Post  
Posted to microsoft.public.excel.misc
Jo Jo is offline
external usenet poster
 
Posts: 113
Default count worksheets



"Mike Anas" wrote:

Gord is showing you a VBA subroutine that will do the trick. I'm not
aware of a built in Excel function that will answer this question for
you without the use of VBA. The following link might be helpful to
you, if you want to learn about creating user-defined functions, which
is what appears to be necessary.

http://www.vertex42.com/ExcelArticle...functions.html

Many thanks but it's sounding a bit beyond my capabilities. I'll just count the sheets!



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,202
Default count worksheets

Gord is showing you a VBA subroutine that will do the trick. I'm not
aware of a built in Excel function that will answer this question for
you without the use of VBA. The following link might be helpful to
you, if you want to learn about creating user-defined functions, which
is what appears to be necessary.

http://www.vertex42.com/ExcelArticle...functions.html


Many thanks but it's sounding a bit beyond my capabilities. I'll just
count the sheets!


Try the following... From any worksheet, press Alt+F11; this will take you
to the VBA editor. Click Insert/Module on the VBA editor's menubar. A code
window will popup that has the title "Book 1 - Module1 (Code)"... copy the
following three lines of code (note that it is slightly different than what
Gord posted) and paste them into that code window

Function CountSheets()
CountSheets = ActiveWorkbook.Sheets.Count
End Function

Now, go back to the worksheet (you can close the VBA editor if you want; the
code you just copied into it will be saved when you save the workbook); type
this into any cell...

=CountSheets()

and press Enter. You should see a count of the number of sheets in your
workbook. You can use CountSheets() inside any formulas you create (in this
workbook) just like it was a regular built-in spreadsheet function.

Rick

  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,180
Default count worksheets

Or without code or formulas:
Right-click on any tab Select All Sheets
Select a cell location that you don't normally use,
say HZ10.
Type in it an odd sequence of letters, say QXYZ.
QXYZ will now appear on all sheets at HZ10
Edit Find QXYZ Find All
The number of sheets will appear in the
lower left corner of the Find window.
A format color instead of QZYZ also works.
This way you can select A1 and not accidentally
overwrite data.
  #8   Report Post  
Posted to microsoft.public.excel.misc
Jo Jo is offline
external usenet poster
 
Posts: 113
Default count worksheets



"Rick Rothstein (MVP - VB)" wrote:

Gord is showing you a VBA subroutine that will do the trick. I'm not
aware of a built in Excel function that will answer this question for
you without the use of VBA. The following link might be helpful to
you, if you want to learn about creating user-defined functions, which
is what appears to be necessary.

http://www.vertex42.com/ExcelArticle...functions.html


Many thanks but it's sounding a bit beyond my capabilities. I'll just
count the sheets!


Try the following... From any worksheet, press Alt+F11; this will take you
to the VBA editor. Click Insert/Module on the VBA editor's menubar. A code
window will popup that has the title "Book 1 - Module1 (Code)"... copy the
following three lines of code (note that it is slightly different than what
Gord posted) and paste them into that code window

Function CountSheets()
CountSheets = ActiveWorkbook.Sheets.Count
End Function

Now, go back to the worksheet (you can close the VBA editor if you want; the
code you just copied into it will be saved when you save the workbook); type
this into any cell...

=CountSheets()

and press Enter. You should see a count of the number of sheets in your
workbook. You can use CountSheets() inside any formulas you create (in this
workbook) just like it was a regular built-in spreadsheet function.

Rick

Thanks Rick - that's what I needed - I can do that

  #9   Report Post  
Posted to microsoft.public.excel.misc
Jo Jo is offline
external usenet poster
 
Posts: 113
Default count worksheets



"Herbert Seidenberg" wrote:

Or without code or formulas:
Right-click on any tab Select All Sheets
Select a cell location that you don't normally use,
say HZ10.
Type in it an odd sequence of letters, say QXYZ.
QXYZ will now appear on all sheets at HZ10
Edit Find QXYZ Find All
The number of sheets will appear in the
lower left corner of the Find window.
A format color instead of QZYZ also works.
This way you can select A1 and not accidentally
overwrite data.

Aah, excellent! Good value.
  #10   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default count worksheets

Herbert

A clever solution.

Just one caveat,,,,,,,,,,,,only worksheets will be counted so if user has chart
sheets they will be missed.


Gord

On Thu, 13 Dec 2007 14:43:02 -0800, Jo wrote:



"Herbert Seidenberg" wrote:

Or without code or formulas:
Right-click on any tab Select All Sheets
Select a cell location that you don't normally use,
say HZ10.
Type in it an odd sequence of letters, say QXYZ.
QXYZ will now appear on all sheets at HZ10
Edit Find QXYZ Find All
The number of sheets will appear in the
lower left corner of the Find window.
A format color instead of QZYZ also works.
This way you can select A1 and not accidentally
overwrite data.

Aah, excellent! Good value.




  #11   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 272
Default count worksheets

=COUNTA('*'!A1)+1

assuming A1 in each sheet is non-blank.

"Jo" wrote:

can you tell how many worksheets are in your workbook without physically
counting them? I have renamed my sheets so they're not consecutively
numbered any more.

  #12   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 20
Default count worksheets



"Herbert Seidenberg" wrote:

Or without code or formulas:
Right-click on any tab Select All Sheets
Select a cell location that you don't normally use,
say HZ10.
Type in it an odd sequence of letters, say QXYZ.
QXYZ will now appear on all sheets at HZ10
Edit Find QXYZ Find All
The number of sheets will appear in the
lower left corner of the Find window.
A format color instead of QZYZ also works.
This way you can select A1 and not accidentally
overwrite data.

  #13   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 661
Default count worksheets

Your formula is great except it doesn't update automatically.

How do you make it update without manually re-entering it each time?

Thanks.



"Rick Rothstein (MVP - VB)" wrote:

Gord is showing you a VBA subroutine that will do the trick. I'm not
aware of a built in Excel function that will answer this question for
you without the use of VBA. The following link might be helpful to
you, if you want to learn about creating user-defined functions, which
is what appears to be necessary.

http://www.vertex42.com/ExcelArticle...functions.html


Many thanks but it's sounding a bit beyond my capabilities. I'll just
count the sheets!


Try the following... From any worksheet, press Alt+F11; this will take you
to the VBA editor. Click Insert/Module on the VBA editor's menubar. A code
window will popup that has the title "Book 1 - Module1 (Code)"... copy the
following three lines of code (note that it is slightly different than what
Gord posted) and paste them into that code window

Function CountSheets()
CountSheets = ActiveWorkbook.Sheets.Count
End Function

Now, go back to the worksheet (you can close the VBA editor if you want; the
code you just copied into it will be saved when you save the workbook); type
this into any cell...

=CountSheets()

and press Enter. You should see a count of the number of sheets in your
workbook. You can use CountSheets() inside any formulas you create (in this
workbook) just like it was a regular built-in spreadsheet function.

Rick


  #14   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 15,768
Default count worksheets

Here's another method...

Create this defined formula
Goto the menu InsertNameDefine
Name: SheetNames
Refers to:

=GET.WORKBOOK(1)&T(NOW())

OK out

Then to count how many sheets are in a file:

=COUNTA(INDEX(SheetNames,0))

--
Biff
Microsoft Excel MVP


"paul" wrote in message
...
Your formula is great except it doesn't update automatically.

How do you make it update without manually re-entering it each time?

Thanks.



"Rick Rothstein (MVP - VB)" wrote:

Gord is showing you a VBA subroutine that will do the trick. I'm not
aware of a built in Excel function that will answer this question for
you without the use of VBA. The following link might be helpful to
you, if you want to learn about creating user-defined functions, which
is what appears to be necessary.

http://www.vertex42.com/ExcelArticle...functions.html

Many thanks but it's sounding a bit beyond my capabilities. I'll just
count the sheets!


Try the following... From any worksheet, press Alt+F11; this will take
you
to the VBA editor. Click Insert/Module on the VBA editor's menubar. A
code
window will popup that has the title "Book 1 - Module1 (Code)"... copy
the
following three lines of code (note that it is slightly different than
what
Gord posted) and paste them into that code window

Function CountSheets()
CountSheets = ActiveWorkbook.Sheets.Count
End Function

Now, go back to the worksheet (you can close the VBA editor if you want;
the
code you just copied into it will be saved when you save the workbook);
type
this into any cell...

=CountSheets()

and press Enter. You should see a count of the number of sheets in your
workbook. You can use CountSheets() inside any formulas you create (in
this
workbook) just like it was a regular built-in spreadsheet function.

Rick




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
count from several worksheets Karen Excel Worksheet Functions 2 May 4th 06 04:26 AM
can i.. do a COUNT through mutiple worksheets? ninetynine Excel Discussion (Misc queries) 2 January 25th 06 01:59 PM
3D Count in all worksheets [email protected] Excel Worksheet Functions 2 October 30th 05 09:47 AM
Count of Worksheets Terry Excel Discussion (Misc queries) 7 February 23rd 05 09:39 AM
How to count # of worksheets? Stephen POWELL Excel Discussion (Misc queries) 4 January 27th 05 02:05 PM


All times are GMT +1. The time now is 05:02 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"