Sub ñðîêè()
' Declare const ""
Const quote As String = """"
Set Trips = Worksheets("Êòî åäåò")
Set Dates = Worksheets("Êîìàíäèðîâêè")
Dim Emploees_Array As New Dictionary
' Declare array of company
Dim Company_Array(2) As String
Dim Trips_Array() As String
' Add name of company in array
Company_Array(0) = "ÍÈÈ " & quote & "Ðàññâåò" & quote
Company_Array(1) = "ÇÀÎ " & quote & "Ñòðîèòåëü" & quote
Company_Array(2) = "Ïðèãëàøåííûå ñïåöèàëèñòû"
For Each test In Company_Array
For i = 2 To Worksheets(test).Cells(2, 1).CurrentRegion.Rows.Count
Emploees_Array.Add Worksheets(test).Cells(i, 1).Value, Worksheets(test).Cells(i, 1)
Next
Next
For Each Worker In Emploees_Array
Enter = 0
For i = 2 To Trips.Cells(1, 1).CurrentRegion.Rows.Count
If Worker = Trips.Cells(i, 2) Then
Enter = Enter + 1
End If
Next
ReDim Trips_Array(Enter)
Key = 0
For i = 2 To Trips.Cells(1, 1).CurrentRegion.Rows.Count
If Worker = Trips.Cells(i, 2) Then
Trips_Array(Key) = Trips.Cells(i, 1)
Key = Key + 1
End If
Next
Emploees_Array.Item(Worker) = Trips_Array
Next
For Each Worker In Emploees_Array
Date_End = 1
For Each Number In Emploees_Array.Item(Worker)
'MsgBox (Number)
For i = 2 To Dates.Cells(1, 1).CurrentRegion.Rows.Count
' Íåÿâíîå ïðåîáðàçîâàíèå òèïà (Cstr)
If Dates.Cells(i, 1).Value = CStr(Number) Then
If Date_End <> 1 Then
If CDate(Dates.Cells(i, 2)) < CDate(Date_End) Then
For j = 2 To Trips.Cells(1, 1).CurrentRegion.Rows.Count
If (Trips.Cells(j, 1) = CStr(Number)) And (Trips.Cells(j, 2) = Worker) Then
Trips.Rows(j).Interior.Color = RGB(255, 204, 204)
End If
Next
End If
Else
Date_End = Dates.Cells(i, 2) + Day(Dates.Cells(i, 3) + 1)
End If
End If
Next
Next
Next
End Sub