Sub timenamecompare4()
Dim lr, i As Long
lr = Cells(Rows.Count, "H").End(xlUp).Row
For i = lr To 2 Step -1
If Cells(i, 18).Value = Cells(i + 1, 18).Value And _
Abs(DateDiff("n", Cells(i, 8).Value, Cells(1 + i, 8).Value)) < 1440 And _
Abs(DateDiff("n", Cells(i, 8).Value, Cells(1 + i, 8).Value)) <> 0 Then
Cells(i, 4).Value = "Yes"
End If
If Cells(i, 18).Value = Cells(i + 1, 18).Value And _
Abs(DateDiff("n", Cells(i, 8).Value, Cells(1 + i, 8).Value)) > 1440 And _
Abs(DateDiff("n", Cells(i, 8).Value, Cells(1 + i, 8).Value)) < 2880 And _
Abs(DateDiff("n", Cells(i, 8).Value, Cells(1 + i, 8).Value)) <> 0 Then
Cells(i, 5).Value = "Yes"
End If
Next
End Sub