View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 10,593
Default Group sheets using code

Function GroupSheets(StartSheet As String, EndSheet As String)
Dim iStart As Long
Dim iEnd As Long
Dim i As Long, j As Long
Dim arySheets

On Error Resume Next
iStart = ActiveWorkbook.Worksheets(StartSheet).Index
iEnd = ActiveWorkbook.Worksheets(EndSheet).Index
On Error GoTo 0
If iStart = 0 Or iEnd = 0 Or iEnd < iStart Then
MsgBox "Invalid"
Exit Function
End If

ReDim arySheets(iEnd - iStart)
For i = iStart To iEnd
arySheets(i - iStart) = ActiveWorkbook.Worksheets(i).Name
Next i

Sheets(arySheets).Select

End Function



--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"J.W. Aldridge" wrote in message
oups.com...
I have several macros that I need to record where I group sheets, then
perform the actions.
I need a code that will group sheets by sheetname range (i.e. "apples"
to "oranges").
I will record myself perfoming the various actions to get the code to
finish it, however, I need a general/ basic grouping code to start off.



Thanx.