Last time in L for each in A

Luke777

Board Regular
Joined
Aug 10, 2020
Messages
246
Office Version
  1. 365
Platform
  1. Windows
Hi all,

Column A contains a bunch of IDs, L contains various times - I would like a lovely bit of code that chucks out a unique list of those ID's with the last associated time on another sheet).

Unfortunately I had a bit of code that would do this for me, but I've lost it.

Here is my example data

121924/12/2021 17:00
121924/12/2021 17:15
121924/12/2021 19:30
121924/12/2021 20:00
121924/12/2021 22:00
121924/12/2021 22:15
121925/12/2021 00:30
93224/12/2021 07:45
93224/12/2021 08:15
93224/12/2021 08:45
93224/12/2021 09:45
93224/12/2021 10:00
93224/12/2021 13:30
93224/12/2021 14:00
93224/12/2021 15:00
93224/12/2021 15:15
93224/12/2021 17:30
91624/12/2021 13:00
91624/12/2021 14:30
91624/12/2021 14:45
91624/12/2021 16:45
91624/12/2021 17:15
91624/12/2021 19:15
91624/12/2021 19:45
91624/12/2021 22:00
91624/12/2021 22:15
91625/12/2021 00:30
54224/12/2021 08:00
54224/12/2021 09:00
54224/12/2021 09:15
54224/12/2021 11:15
54224/12/2021 11:30
54224/12/2021 12:39
54224/12/2021 13:09
54224/12/2021 14:15
54224/12/2021 14:30
54224/12/2021 15:30
54224/12/2021 15:45
54224/12/2021 16:45


The results on sheet2 should look something like the following

121925/12/2021 00:30
93224/12/2021 17:30
91625/12/2021 00:30
54224/12/2021 16:45


with the times now in K instead of L

Thanks everyone
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Does it need to be code?
It can be done with two single-cell formulas.

Luke777.xlsm
AK
1121925/12/2021 00:30
293224/12/2021 17:30
391625/12/2021 00:30
454224/12/2021 16:45
5
Sheet2
Cell Formulas
RangeFormula
A1:A4A1=UNIQUE(Sheet1!A1:A39)
K1:K4K1=MAXIFS(Sheet1!L1:L39,Sheet1!A1:A39,A1#)
Dynamic array formulas.


If you are not sure of the exact range in Sheet1 then change the Sheet2 A1 formula to something like this

Excel Formula:
=UNIQUE(FILTER(Sheet1!A1:A1000,Sheet1!A1:A1000<>""))
 
Last edited:
Upvote 0
Does it need to be code?
It can be done with two single-cell formulas.

Luke777.xlsm
AK
1121925/12/2021 00:30
293224/12/2021 17:30
391625/12/2021 00:30
454224/12/2021 16:45
5
Sheet2
Cell Formulas
RangeFormula
A1:A4A1=UNIQUE(Sheet1!A1:A39)
K1:K4K1=MAXIFS(Sheet1!L1:L39,Sheet1!A1:A39,A1#)
Dynamic array formulas.


If you are not sure of the exact range in Sheet1 then change the Sheet2A1 formula to something like this

Excel Formula:
=UNIQUE(FILTER(Sheet1!A1:A1000,Sheet1!A1:A1000<>""))
Thanks!

I keep forgetting formulas like this exist.. seems like a much simpler solution than any sort of loop I had in mind. I'll give it a go and let you know how I get on :) If you don't hear anything else it worked perfectly and I'll mark as answer :)
 
Upvote 0
Hi
If code then try
VBA Code:
Sub test()
    lr = Sheets("sheet1").Cells(Rows.Count, 1).End(xlUp).Row
    a = Sheets("sheet1").Cells(1, 1).Resize(Sheets("sheet1").Cells(Rows.Count, 1).End(xlUp).Row, 12)
    With CreateObject("scripting.dictionary")
        For i = 1 To UBound(a)
            If Not .Exists(a(i, 1)) Then
                .Add a(i, 1), a(i, 12)
            Else
                .Item(a(i, 1)) = a(i, 12)
            End If
        Next
        Sheets("sheet2").Cells(1, 1).Resize(.Count) = Application.Transpose(.Keys)
        Sheets("sheet2").Cells(1, 11).Resize(.Count) = Application.Transpose(.Items)
    End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,956
Messages
6,122,465
Members
449,085
Latest member
ExcelError

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top