ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Sheet selection (https://www.excelbanter.com/excel-programming/312682-sheet-selection.html)

No Name

Sheet selection
 
Hello,

Using VBA for Excel
How could I go about selecting all of the sheets in a
workbook except for 1 particular sheet. I would like to do
this without having to state the name of each individual
sheet, except for the 1 particular sheet.

Thank You,

Tom Ogilvy

Sheet selection
 
Sub Tester1()
Const shName As String = "Sheet1"
Dim sh As Worksheet, i As Long, j As Long
i = 1
j = 0
For Each sh In ThisWorkbook.Worksheets
j = j + 1
If LCase(sh.Name) < LCase(shName) Then
sh.Select sh.Name = Worksheets(i).Name
ElseIf j = 1 Then
i = j + 1
End If
Next


End Sub

--
Regards,
Tom Ogilvy


wrote in message
...
Hello,

Using VBA for Excel
How could I go about selecting all of the sheets in a
workbook except for 1 particular sheet. I would like to do
this without having to state the name of each individual
sheet, except for the 1 particular sheet.

Thank You,





All times are GMT +1. The time now is 08:19 PM.

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