Selecting all of the sheets in a workbook

C

Cyberwolf

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.
 
J

JW

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
 
J

JW

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 said:
sheets.select

--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(e-mail address removed)
Cyberwolf said:
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
 

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

Top