You're welcome!
A slight improvement:
Private Sub CommandButton1_Click(): Dim Agent As Object, K 'Dictionary keys
Dim wt As Worksheet, wp As Worksheet, x As Long, y As Long, u As Long, LR As Long
Set wt = Worksheets("Tracker"): Set wp = Worksheets("People_List")
LR = wp.Range("A" & wp.Rows.Count).End(xlUp).Row: y = 3
Set Agent = CreateObject("Scripting.Dictionary")
For x = 1 To LR
If wp.Cells(x, 2) = "In" Then Agent.Item(Trim(wp.Cells(x, 1))) = x
Next x: K = Agent.Keys()
LR = wt.Range("I" & wt.Rows.Count).End(xlUp).Row
For y = 3 To LR Step 11
If u > UBound(K) Then Exit Sub
If wt.Cells(y, 11) = "" Then
For x = LBound(K) To UBound(K)
If K(x) <> Trim(wt.Cells(y, 1)) And Agent.Item(K(x)) <> 0 Then
wt.Cells(y, 11) = K(x): Agent.Item(K(x)) = 0: u = u + 1: Exit For: End If
Next x
Else: Agent.Item(Trim(wt.Cells(y, 11))) = 0
End If: Next y
End Sub
Bookmarks