Sub SetScheduleTest4()
Dim ws1 As Worksheet, ws2 As Worksheet, ws3 As Worksheet
Dim rng1 As Range, rng2 As Range, rng3 As Range
Dim c As Range
Dim MyDic As Object
Set MyDic = CreateObject("scripting.dictionary")
Set ws1 = Sheets("Release Master")
Set ws2 = Sheets("Change Master")
Set ws3 = Sheets("Calendar")
ws3.Cells.Clear
ws3.Columns(1).NumberFormat = "d-mmm-yy"
Set rng1 = ws1.Range(ws1.[k2], ws1.Cells(Rows.Count, "k").End(xlUp))
For Each c In rng1
If MyDic.exists(c.Value) = False Then
ws3.Cells(Rows.Count, "A").End(xlUp).Offset(1, 0) = c
ws3.Cells(Rows.Count, "A").End(xlUp).Offset(0, 1) = "PM - " & ws1.Cells(c.Row, "H") & ", " & ws1.Cells(c.Row, "B") & ", " & ws1.Cells(c.Row, "C") & ", " & ws1.Cells(c.Row, "D") & ", " & ws1.Cells(c.Row, "E") & ", " & ws1.Cells(c.Row, "G") & ws1.Cells(c.Row, "P") & Chr(10)
MyDic.Add c.Value, 1
Else
Set rng2 = ws3.Columns("A").Find(c.Value)
rng2.Offset(0, 1) = rng2.Offset(0, 1) & "PM - " & ws1.Cells(c.Row, "H") & ", " & ws1.Cells(c.Row, "B") & ", " & ws1.Cells(c.Row, "C") & ", " & ws1.Cells(c.Row, "D") & ", " & ws1.Cells(c.Row, "E") & ", " & ws1.Cells(c.Row, "G") & ", " & ws1.Cells(c.Row, "P") & Chr(10)
End If
Next c
Set rng2 = ws2.Range(ws2.[g2], ws2.Cells(Rows.Count, "g").End(xlUp))
For Each c In rng2
If MyDic.exists(c.Value) = False Then
ws3.Cells(Rows.Count, "A").End(xlUp).Offset(1, 0) = c
ws3.Cells(Rows.Count, "A").End(xlUp).Offset(0, 2) = ws2.Cells(c.Row, "B") & ", " & ws2.Cells(c.Row, "C") & ", " & ws2.Cells(c.Row, "R") & ", " & ws2.Cells(c.Row, "J") & Chr(10) & Chr(10)
MyDic.Add c.Value, 1
Else
Set rng2 = ws3.Columns("A").Find(c.Value)
rng2.Offset(0, 2) = rng2.Offset(0, 2) & ws2.Cells(c.Row, "B") & ", " & ws2.Cells(c.Row, "C") & ", " & ws2.Cells(c.Row, "R") & ", " & ws2.Cells(c.Row, "J") & Chr(10) & Chr(10)
End If
Next c
With ws3
.Columns(1).NumberFormat = "d-mmm-yy"
.UsedRange.Sort Key1:=Range("A2"), Order1:=xlAscending
.UsedRange.Borders.LineStyle = xlContinuous
.UsedRange.Borders.Weight = xlThin
.UsedRange.Borders.ColorIndex = xlAutomatic
End With
End If
End Sub
Cells.Find(What:=FindDate, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
Open in new window