ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   group all sheets after (https://www.excelbanter.com/excel-programming/428177-group-all-sheets-after.html)

J.W. Aldridge

group all sheets after
 
Need to know how to express the following....


group all sheets in a workbook after sheet "apples"
or
group all sheets in a workbook after the 3rd sheet in workbook.

Dave Peterson

group all sheets after
 
Option Explicit
Sub testme()
Dim FirstIndex As Long
Dim iCtr As Long

FirstIndex = Sheets("Apples").Index 'or 3 or 4

For iCtr = FirstIndex To Sheets.Count
Sheets(iCtr).Select Replace:=CBool(iCtr = FirstIndex)
Next iCtr

End Sub

After the 3rd means include the third? Start with the first sheet or index that
you want grouped.

And After means to the right, correct?

"J.W. Aldridge" wrote:

Need to know how to express the following....

group all sheets in a workbook after sheet "apples"
or
group all sheets in a workbook after the 3rd sheet in workbook.


--

Dave Peterson

Gary Keramidas

group all sheets after
 
here's another way, there're always multiple ways to do things.

Option Explicit

Sub test()
Dim i As Long
Application.ScreenUpdating = False
For i = Worksheets("Apples").Index To Worksheets.Count
Worksheets(i).Select False
Next
Application.ScreenUpdating = True
End Sub

Sub test2()
Dim i As Long
Application.ScreenUpdating = False
For i = 3 To Worksheets.Count
Worksheets(i).Select False
Next
Application.ScreenUpdating = True
End Sub

--

Gary Keramidas
Excel 2003


"J.W. Aldridge" wrote in message
...
Need to know how to express the following....


group all sheets in a workbook after sheet "apples"
or
group all sheets in a workbook after the 3rd sheet in workbook.



Dave Peterson

group all sheets after
 
This will work if the current selected sheet(s) is/are to the left of that
Apples/3 sheet.

Gary Keramidas wrote:

here's another way, there're always multiple ways to do things.

Option Explicit

Sub test()
Dim i As Long
Application.ScreenUpdating = False
For i = Worksheets("Apples").Index To Worksheets.Count
Worksheets(i).Select False
Next
Application.ScreenUpdating = True
End Sub

Sub test2()
Dim i As Long
Application.ScreenUpdating = False
For i = 3 To Worksheets.Count
Worksheets(i).Select False
Next
Application.ScreenUpdating = True
End Sub

--

Gary Keramidas
Excel 2003

"J.W. Aldridge" wrote in message
...
Need to know how to express the following....


group all sheets in a workbook after sheet "apples"
or
group all sheets in a workbook after the 3rd sheet in workbook.


--

Dave Peterson


All times are GMT +1. The time now is 07:11 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com