Using a macro how do I group every sheet within a book?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Using a macro how do I group every sheet within a book?

I have created a macro, but find that the names of the sheets will differ
every time and hence I need a mechanism that will automatically select all of
them to allow me to undertake editing within them all at the same time.
 
Dim arySheets
Dim sh
Dim i As Long

ReDim arySheets(ActiveWorkbook.Worksheets.Count - 1)

For Each sh In ActiveWorkbook.Worksheets
arySheets(i) = sh.Name
i = i + 1
Next sh
Sheets(arySheets).Select


--

HTH

RP
(remove nothere from the email address if mailing direct)
 
Bob,

Many thanks

Bob Phillips said:
Dim arySheets
Dim sh
Dim i As Long

ReDim arySheets(ActiveWorkbook.Worksheets.Count - 1)

For Each sh In ActiveWorkbook.Worksheets
arySheets(i) = sh.Name
i = i + 1
Next sh
Sheets(arySheets).Select


--

HTH

RP
(remove nothere from the email address if mailing direct)
 
Another way:
Sheets.Select
or
worksheets.select

(if you want to avoid selecting non-worksheets (like Chart sheets).)
 

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

Back
Top