Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Selecting all of the sheets in a workbook

How would I go creating a macro or VBA that selects all of the worksheets in
a given workbook. This needs to work regardless of how many sheets there
are. i.e. workbook1 may contain 5 worksheets where as workbook2 may
contain 8.
--
Cyberwolf
Finder of Paths, Hunter of Prey
Ghost of the Night, Shadow of Day
The Wolf
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 638
Default Selecting all of the sheets in a workbook

This will select all visible sheets.
Sub selectAll()
Dim ws As Worksheet
For Each ws In Sheets
If ws.Visible Then ws.Select False
Next
End Sub
Cyberwolf wrote:
How would I go creating a macro or VBA that selects all of the worksheets in
a given workbook. This needs to work regardless of how many sheets there
are. i.e. workbook1 may contain 5 worksheets where as workbook2 may
contain 8.
--
Cyberwolf
Finder of Paths, Hunter of Prey
Ghost of the Night, Shadow of Day
The Wolf


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 638
Default Selecting all of the sheets in a workbook

Don, that could will work perfectly as long as no sheets are hidden.
If there are hidden sheets in the workbook, a 1004 error occurs.

Regards,
Jeff
Don Guillett wrote:
sheets.select

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Cyberwolf" wrote in message
...
How would I go creating a macro or VBA that selects all of the worksheets
in
a given workbook. This needs to work regardless of how many sheets there
are. i.e. workbook1 may contain 5 worksheets where as workbook2
may
contain 8.
--
Cyberwolf
Finder of Paths, Hunter of Prey
Ghost of the Night, Shadow of Day
The Wolf


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
selecting a single sheet from a volume of sheets in a workbook No News Excel Worksheet Functions 12 July 1st 06 05:29 AM
Selecting data from 1 workbook to copy and paste to a 2nd workbook JackSpam Excel Programming 2 July 20th 05 02:33 AM
VBA: selecting sheets and copy them to a workbook Stephan Otto Excel Programming 5 November 2nd 04 02:18 PM
selecting sheets kevin Excel Programming 4 November 27th 03 11:06 PM
Changing the value in multiple sheets without selecting those sheets herm Excel Programming 3 October 14th 03 03:50 PM


All times are GMT +1. The time now is 12:31 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"