I'm not sure exactly what the results should be, but if you store the row number "i" as the item, instead of the key then you can use that row as the Datum for copying down, based on each "Key", as shown in the "Else" statement.
Try the code below for results on sheet2.
Sub MG20Jul58
Dim a, dic As Object, s As String, i As Long, j As Long, col As Variant, Ray, n As Long
a = ThisWorkbook.Worksheets("Sheet5").Range("A1").CurrentRegion.Value
a = Application.Index(a, Evaluate("ROW(1:" & UBound(a, 1) & ")"), [{3,7,13,14,15,16,17,18,19,20,21}])
Set dic = CreateObject("Scripting.Dictionary")
dic.CompareMode = 1
For i = LBound(a) To UBound(a)
s = a(i, 1) & vbTab & a(i, 2)
If Not dic.Exists(s) Then
dic.Add s, i
For j = LBound(a, 2) To UBound(a, 2)
If j = 1 Or j = 3 Or j = 6 Or j = 9 Then
If i > 1 Then a(i, j) = CLng(Application.WorksheetFunction.WorkDay(CDate(a(i, 1)), IIf(j = 1, 0, Val(j / 3))))
End If
Next j
Else
For n = 1 To UBound(a, 2)
a(i, n) = a(dic(s), n)
Next n
End If
Next i
Sheets("Sheet2").Range("A1").Resize(UBound(a, 1), UBound(a, 2)).Value = a
Regards Mick
Bookmarks