mikenelena
Board Regular
- Joined
- Mar 5, 2018
- Messages
- 139
- Office Version
- 365
- Platform
- Windows
We have two groups of employees, and they need different handling for payroll. To loop through 1 type of employee, I simply excluded the others in my For Each statement, because there are only a few. For that second group though, it is inefficient and unwieldy to exclude an entire list. (Every time an employee comes or goes, I'd have to change the code.) Below is what I'm looking to accomplish, but I'm sure there is a better way. My gut says maybe a case statement would do it, but I'm not sure how to go about it. Can anyone help me with this?
Thanks so much!
Thanks so much!
Code:
Sub LoopGetAdminPayrollData()
Dim ws As Worksheet
Application.ScreenUpdating = False
For Each ws In Worksheets
If ws.Name <> "Main" And ws.Name <> "Guide" And ws.Name <> "Sum" And ws.Name <> "Abb" And ws.Name <> "Bar" And ws.Name <> "Bur" _
And ws.Name <> "Car" And ws.Name <> "Duc" And ws.Name <> "Jef" And ws.Name <> "Fit" And ws.Name <> "Gil" And ws.Name <> "Hec" _
And ws.Name <> "JP" And ws.Name <> "Jud" And ws.Name <> "Nap" And ws.Name <> "Pow" And ws.Name <> "BR" And ws.Name <> "JR" _
And ws.Name <> "Ree" And ws.Name <> "TJ" And ws.Name <> "Ben" And ws.Name <> "Tet" And ws.Name <> "Var" And ws.Name <> "Bill" _
And ws.Name <> "Yoh" And ws.Name <> "Dan" Then
Worksheets(ActiveSheet.Index + 1).Select
Call GetAdminData
End If
Next ws
End Sub