ammend to exlude sheet(s)

  • Thread starter Thread starter J.W. Aldridge
  • Start date Start date
J

J.W. Aldridge

Need to exlude (add to code) sheets "S2" and "S4" sheets along with
"S3".


Option Explicit


Sub testme3()


Dim mysheets
Dim wks As Worksheet
Dim firstselected As Boolean


Set mysheets = ActiveWindow.SelectedSheets


firstselected = False
For Each wks In mysheets
If ucase(wks.Name) = "S3" Then
'do nothing
ElseIf Not firstselected Then
wks.Select
firstselected = True
Else
wks.Select Replace:=False
End If
Next wks


End Sub
 
Option Explicit
Sub testme3()

Dim mySheets as Object
Dim wks As Worksheet
Dim FirstSelected As Boolean

Set mySheets = ActiveWindow.SelectedSheets

FirstSelected = False
For Each wks In mySheets
Select Case UCase(wks.Name)
Case Is = "S2", "S3", "S4"
'do nothing
Case Else
If Not FirstSelected Then
wks.Select
FirstSelected = True
Else
wks.Select Replace:=False
End If
End Select
Next wks

End Sub
 
Back
Top