• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Find the youngest date in range(s)

Belleke

Well-Known Member
Hey ninjas,
I am looking for some code to find the youngest date in blocks.
Situation
In column A i have forklift numbers
In column I I have dates
Situation
Column A Column I
fl1 10/12/2016
fl1 10/02/2017
fl1 10/02/2018
fl2 05/06/2016
fl2 15/10/2016
fl2 20/01/2018
Im am looking for this
Column A Column I Column K
fl1 10/12/2016
fl1 10/02/2017
fl1 10/02/2018 youngest date
fl2 05/06/2016
fl2 15/10/2016
fl2 20/01/2018 youngest date.
Ther can be empty rows in between.
Please advice
 
9600 rows is nothing really, how expensive are rest of your calculations etc?

If performance is an issue, use Pivot Table to show all the youngest dates.

But upload sample workbook as I asked, with 25 or so data that accurately represent your actual data, if you need further help.
 
Yes Chihiro, that is what I mean by youngest date in blocks.
Something like youngest date in column K if value in column A is the same as value offset(-1,0)
 
VBA
Code:
Sub Demo()
Dim ar
ar = Range("A2:K" & Cells(Rows.Count, 1).End(xlUp).Row).Value2

With CreateObject("Scripting.Dictionary")
    For i = 1 To UBound(ar)
        If .Exists(ar(i, 1)) Then
            If ar(i, 8) > .Item(ar(i, 1)) Then
                .Item(ar(i, 1)) = ar(i, 9) & "," & i + 1
            End If
        Else
            .Item(ar(i, 1)) = ar(i, 9) & "," & i + 1
        End If
    Next
    For Each Key In .Keys
        Cells(Split(.Item(Key), ",")(1), 11) = "YD"
    Next
End With
End Sub
 
Hi chirayu and chihiro,
Both solutions work.
Thanks, problem solved.
I push the like button for the both of you.
 
Back
Top