Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
tc tc is offline
external usenet poster
 
Posts: 40
Default Count number of sheets

Hi. I want to create a macro that will count the number of sheets in a
particular workbook. Is this possible?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Count number of sheets

One way:

Public Function NumberOfSheets(Optional ByRef wb As Workbook) As Long
If wb Is Nothing Then Set wb = ActiveWorkbook
NumberOfSheets = wb.Sheets.Count
End Function

Example:

Dim wbParticular As Workbook
Set wbParticular = Workbooks("Particular.xls")
MsgBox "Workbook " & vbNewLine & vbNewLine & " " & _
wbParticular.Name & vbNewLine & vbNewLine & _
"has " & NumberOfSheets(wbParticular) & " sheets."




In article . com,
tc wrote:

Hi. I want to create a macro that will count the number of sheets in a
particular workbook. Is this possible?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 791
Default Count number of sheets

NumberofSheets = ThisWorkbook.Worksheets.Count
--
If this posting was helpful, please click on the Yes button.
Regards,

Michael Arch.




"tc" wrote:

Hi. I want to create a macro that will count the number of sheets in a
particular workbook. Is this possible?


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Count number of sheets

once again check your other posts. One post is enough to get a question
answered.

"tc" wrote:

Hi. I want to create a macro that will count the number of sheets in a
particular workbook. Is this possible?


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Count number of sheets

or if there are chartsheets as well

Activeworkbook.Sheets.count

--
regards,
Tom Ogilvy


"Michael" wrote:

NumberofSheets = ThisWorkbook.Worksheets.Count
--
If this posting was helpful, please click on the Yes button.
Regards,

Michael Arch.




"tc" wrote:

Hi. I want to create a macro that will count the number of sheets in a
particular workbook. Is this possible?


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
How to count number of sheets booshi Excel Worksheet Functions 3 April 25th 23 11:45 AM
Count number of sheets tc Excel Discussion (Misc queries) 3 September 10th 07 06:01 PM
Count number of sheets tc Excel Worksheet Functions 5 September 10th 07 05:22 PM
Count number of sheets JHL Excel Discussion (Misc queries) 3 September 6th 07 09:06 PM
Count the number of sheets. Olle Svensson Excel Discussion (Misc queries) 3 March 13th 06 02:30 PM


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

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"