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

P

Pank Mehta

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

Bob Phillips

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)
 
P

Pank Mehta

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)
 
D

Dave Peterson

Another way:
Sheets.Select
or
worksheets.select

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