ammend to exlude sheet(s)

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
 
D

Dave Peterson

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top