Sub Find5LatestDates()
Dim Latest(1 To 5) As Date
Dim myC As Range
Dim i As Integer
Dim j As Integer
For Each myC In Range("A1:A100")
For i = 1 To 5
If myC.Value = Latest(i) Then GoTo NextDate
Next i
For i = 1 To 5
If myC.Value > Latest(i) Then
For j = 4 To i Step -1
Latest(j + 1) = Latest(j)
Next j
Latest(i) = myC.Value
GoTo NextDate
End If
Next i
NextDate:
Next myC
For i = 1 To 5
MsgBox Format(Latest(i), "mm/dd/yyyy")
Next i
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.