Sub ñðîêè Declare const Const quote As String Set Trips Worksheets Êòî

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
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