For ii = 2 To kk - 1 Count = 0 For i = 2 To whos_going.UsedRange.Rows.Count If (whos_going.Cells(i, 1).Value = komandir.Cells(ii, 12)) Then whos_going.Cells(i, 4).Value = "зарубежная" End If Next i For i1 = 2 To whos_going.UsedRange.Rows.Count If (whos_going.Cells(i1, 4).Value = "зарубежная") Then For j = 1 To temp_list.UsedRange.Rows.Count If (whos_going.Cells(i1, 2).Value = temp_list.Cells(j, 1)) Then whos_going.Cells(i1, 3).Value = temp_list.Cells(j, 2) Count = Count + 1 End If Next j End If Next i1 Next ii For ii = 2 To kk - 1 ' Count = 0 For i1 = 2 To whos_going.UsedRange.Rows.Count If (whos_going.Cells(i1, 4).Value = "зарубежная") Then For j = 1 To temp_list.UsedRange.Rows.Count If (whos_going.Cells(i1, 2).Value = temp_list.Cells(j, 1)) Then whos_going.Cells(i1, 3).Value = temp_list.Cells(j, 2) Count = Count + 1 ' whos_going.Cells(i1, 5).Value = Count End If ' Count = Count + 1 whos_going.Cells(i1, 5).Value = Count Next j End If Count = 0 Next i1 Next ii