PDA

View Full Version : Solved: Count tabs in Workbook



IrishCharm
05-28-2008, 05:00 AM
Hi,

I am looking for help in runnning a quick macro that counts the number of tabs in a workbook, without necessarily knowing the names of those tabs or their order.

For example workbook with tabs:
"Control"
"Sheet1"
"Sheet2"
"Sheet4"

would return 4 and
"Sheet4"
"Control"
"Sheet2"
"Sheet1"
would return 4.

Any help would be great

Bob Phillips
05-28-2008, 05:09 AM
Activeworkbook.Sheets.Count

mdmackillop
05-28-2008, 05:13 AM
Sub test()
Dim sh, i as long
MsgBox Worksheets.Count '(excludes charts)
'or
MsgBox Sheets.Count

'Exclude hidden sheets
For Each sh In Sheets
If sh.Visible = True Then i = i + 1
Next
MsgBox i
End Sub

IrishCharm
05-28-2008, 05:16 AM
Thats great thanks for your help

Sarah

CreganTur
05-28-2008, 06:03 AM
This example might also be useful to you.

I did not make it...can't even remember where I got it from now. I'd give credit to the maker if I could remember who it was:think:

Bob Phillips
05-28-2008, 06:09 AM
You got it from Rob Bovey (directly or indirectly).

CreganTur
05-28-2008, 06:16 AM
You got it from Rob Bovey (directly or indirectly).

It would be indirectly. Someone sent this to me as a resource when I was trying to figure out how to grab worksheet names.

Good resource though:thumb