Sub First Dim As Integer Dim As Integer Dim target As String Dim perio

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
Sub First()
Dim i As Integer
Dim j As Integer
Dim target As String
Dim period As Integer
For i = 2 To 298 Step 1
Worksheets("Командировки").Activate
target = Cells(i, 4)
period = Cells(i, 3)
Worksheets("Список целей").Activate
For j = 2 To 9 Step 1
If (Cells(j, 1) = target) Then
If (Cells(j, 2) < period) Then
period = Cells(j, 2)
Worksheets("Командировки").Activate
Cells(i, 3) = period
Exit For
End If
End If
Next j
Next i
End Sub