Sub Task1 Declare sheets Set Trips Worksheets Eiiaiae iaee Set Goals W

 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
Sub Task1()
' Declare sheets
Set Trips = Worksheets("Eiiaiae?iaee")
Set Goals = Worksheets("Nienie oaeae")
' Declare an associative array
Dim Goal_Array As New Dictionary
' Declare variables for lengths
Dim Goal_Row, Trip_Row As Integer
' Gets the length of sheets
Goal_Row = Goals.Cells(2, 1).CurrentRegion.Rows.Count
Trip_Row = Trips.Cells(2, 1).CurrentRegion.Rows.Count
' Fill associative array
For i = 2 To Goal_Row
Goal_Array.Add Goals.Cells(i, 1).Value, Goals.Cells(i, 2).Value
Next i
' Loop through the duration of the stay
For i = 2 To Trip_Row
' Checks for the purpose in the array
If Goal_Array.Item(Trips.Cells(i, 4).Value) Then
' Validates travel dates
If (CInt(Goal_Array.Item(Trips.Cells(i, 4).Value)) < CInt(Trips.Cells(i, 3))) Then
' Change color
Trips.Cells(i, 3).Interior.Color = RGB(255, 219, 190)
' Change the duration of the stay on the permissible
Trips.Cells(i, 3) = Goal_Array.Item(Trips.Cells(i, 4).Value)
End If
End If
Next
End Sub