Ark68
Well-known Member
- Joined
- Mar 23, 2004
- Messages
- 4,665
- Office Version
- 365
- 2016
- Platform
- Windows
I have this code:
In an effort to exclude worksheets named "EVE1", "EVE", EVL", I added the if/endif in blue. But this doesn't appear to be working as those sheets are still being included.
Rich (BB code):
Sub staffintegrity()
'Stop
Dim rngpda As Range
Dim rwpdaed As Long 'last row of pda range
Dim bunm As String
'hide unstaffed crews
For Each ws9 In wb_data.Worksheets
Application.DisplayAlerts = False
Debug.Print ws9.Name
bunm = ws9.Name
If ws9.Name Like "Sheet*" Then
ws9.Delete
Debug.Print bunm & " deleted."
'Exit For
ElseIf ws9.Name = "Services" Then
ws9.Delete
Debug.Print bunm & " deleted."
'Exit For
ElseIf ws9.Tab.Color = vbRed Then
ws9.Visible = xlhiddensheet
Debug.Print bunm & " hidden."
'Exit For
End If
Application.DisplayAlerts = True
Next ws9
cntsh = 0 'count of visible sheets
For Each ws9 In wb_data.Worksheets
If ws9.Visible = xlSheetVisible Then
If Not ws9.Name Like "EV*" Then
cntsh = cntsh + 1
With ws9
. . . <code> . . .
End With
End If
ttsnr = ttsnr + tsnr
MsgBox ccnt & " cells analysed in worksheet: " & ws9.Name & Chr(13) & tsnr & " invalid names were replaced.", vbInformation, "INTEGRITY: OK Worksheet: " & ws9.Name
tccnt = tccnt + ccnt
End If
Next ws9
MsgBox tccnt & " cells analysed in " & cntsh & " worksheets." & Chr(13) & ttsnr & " invalid names were replaced.", vbInformation, "INTEGRITY: OK Worbkbook: " & wb_data.Name
End Sub
In an effort to exclude worksheets named "EVE1", "EVE", EVL", I added the if/endif in blue. But this doesn't appear to be working as those sheets are still being included.