Sub assign_users()
'MACRO for ASSIGNING USERS
Dim i As Integer, merYlene_count As Integer, kevin_count As Integer, Amy_count As Integer, david_count As Integer, rocky_count As Integer, _
kimberly_count As Integer, sam_count As Integer
merYlene_count = 0
kevin_count = 0
Amy_count = 0
david_count = 0
rocky_count = 0
kimberly_count = 0
sam_count = 0
For i = 2 To Range("A1").End(xlDown).Row
'assigning to merYlene and Kevin
If (Cells(i, 1) = "001" Or Cells(i, 1) = "002" Or Cells(i, 1) = "007") _
And Cells(i, 3) = "" And Cells(i, 4) = "F" And Cells(i, 5) = "0" Then
If merYlene_count < 70 Then
Cells(i, 2) = "merYlene"
merYlene_count = merYlene_count + 1
ElseIf kevin_count < 70 Then
Cells(i, 2) = "kevin"
kevin_count = kevin_count + 1
Else
End If
End If
'assigning to Amy
If (Cells(i, 1) = "001" Or Cells(i, 1) = "002" Or Cells(i, 1) = "007") _
And Cells(i, 3) = "" And Cells(i, 4) = "M" And Cells(i, 5) = "0" Then
If Amy_count < 35 Then
Cells(i, 2) = "Amy"
Amy_count = Amy_count + 1
End If
End If
'assigning to david
If Cells(i, 1) = "011" And Cells(i, 3) = "" And Cells(i, 5) = "0" Then
If david_count < 70 Then
Cells(i, 2) = "david"
david_count = david_count + 1
End If
End If
'assigning to rocky
If Cells(i, 1) = "012" And Cells(i, 3) = "" And Cells(i, 5) = "0" Then
If rocky_count < 70 Then
Cells(i, 2) = "rocky"
rocky_count = rocky_count + 1
End If
End If
'assigning to kimberly
If Cells(i, 1) = "013" And Cells(i, 3) = "" And Cells(i, 5) = "0" Then
If kimberly_count < 70 Then
Cells(i, 2) = "kimberly"
kimberly_count = kimberly_count + 1
End If
End If
'assigning to sam
If Cells(i, 1) = "015" And Cells(i, 3) = "" And Cells(i, 5) = "0" Then
If sam_count < 70 Then
Cells(i, 2) = "sam"
sam_count = sam_count + 1
End If
End If
Next i
'merYlene if still less than 70 assigned to this user
For i = 2 To Range("A1").End(xlDown).Row
If Cells(i, 1) = "017" And Cells(i, 2) = "" And Cells(i, 3) = "" And Cells(i, 5) = "0" Then
If merYlene_count < 70 Then
Cells(i, 2) = "merYlene"
merYlene_count = merYlene_count + 1
Else
Exit For
End If
End If
Next i
End Sub
Bookmarks