Excel VBA filter ID's on most recent update

MichaelJ2600

New Member
Joined
Apr 17, 2023
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Hello all

This is a continuation of :


As I believe I have the same need, but can't get the solution to work. There was a text advising me to create a new post, as the referred was very old, so not trying to be annoying by raising a new thread.

I simply can't get this solution to work. I believe that I have the same setup and requirements as in post #7, however my dates are in column J (10). What I don't understand is, how this filter will look at the Component names in post #7 example, and then filter for the most recent update date in column F (6).

What I want to achieve is one line with the most recent update for each Task ID (column A).

My data:

2023-04-17 21_02_15-TTNIncidentNotes.xlsx - Excel.png


My target :

2023-04-17 21_13_04-TTNIncidentNotes.xlsx - Excel.png


My code:

VBA Code:
Dim myDate As Date: myDate = Application.Max(Columns(10))
Columns(10).AutoFilter Field:=1, Criteria1:="=" & Format(myDate, [J2].NumberFormat)

I really appreciate any help as I'm stuck.

Thanks
Michael
 

Attachments

  • 2023-04-17 21_02_15-TTNIncidentNotes.xlsx - Excel.png
    2023-04-17 21_02_15-TTNIncidentNotes.xlsx - Excel.png
    9.5 KB · Views: 5

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Here is one way.

Book1
ABCDE
1IDSubmit DateIDDate
2TAS0000039637254/30/2021 4:54TAS0000039637254/30/2021 4:54
3TAS0000040525045/26/2021 11:45TAS0000040525045/26/2021 11:45
4TAS0000040936788/16/2021 9:28TAS0000040936788/16/2021 9:39
5TAS0000040936788/16/2021 9:39TAS0000041149337/7/2021 10:33
6TAS0000041149336/14/2021 6:30
7TAS0000041149336/25/2021 1:01
8TAS0000041149337/7/2021 10:33
9TAS0000041149336/22/2021 8:10
Sheet3
Cell Formulas
RangeFormula
D2:E5D2=LET(id,A2:A9,sd,B2:B9,u,UNIQUE(id),HSTACK(u,MAXIFS(sd,id,u)))
Dynamic array formulas.
 
Upvote 0
Here is one way.

Book1
ABCDE
1IDSubmit DateIDDate
2TAS0000039637254/30/2021 4:54TAS0000039637254/30/2021 4:54
3TAS0000040525045/26/2021 11:45TAS0000040525045/26/2021 11:45
4TAS0000040936788/16/2021 9:28TAS0000040936788/16/2021 9:39
5TAS0000040936788/16/2021 9:39TAS0000041149337/7/2021 10:33
6TAS0000041149336/14/2021 6:30
7TAS0000041149336/25/2021 1:01
8TAS0000041149337/7/2021 10:33
9TAS0000041149336/22/2021 8:10
Sheet3
Cell Formulas
RangeFormula
D2:E5D2=LET(id,A2:A9,sd,B2:B9,u,UNIQUE(id),HSTACK(u,MAXIFS(sd,id,u)))
Dynamic array formulas.
Oh, I'm sorry if I was not clear. I'm trying to solve this in a VBA macro, with the purpose to import the result to a new sheet.

/Michael
 
Upvote 0
How about this? I have it outputting to range D2. You can change that line for wherever you want the results.

VBA Code:
Sub MJ()
Dim AR() As Variant:        AR = Range("A2:B" & Range("A" & Rows.Count).End(xlUp).Row).Value2
Dim SD As Object:           Set SD = CreateObject("Scripting.Dictionary")

For i = 1 To UBound(AR)
    If SD(AR(i, 1)) < AR(i, 2) Then SD(AR(i, 1)) = AR(i, 2)
Next i

With Range("D2").Resize(SD.Count)
    .Value = Application.Transpose(SD.keys())
    .Offset(, 1).Value = Application.Transpose(SD.items())
End With
End Sub
 
Upvote 0
Hello Irobbo314

I really appreciate your help, but couldn't get it to work, so took the road down to Power BI instead, where I'm, more comfortable. Thanks again, for express-help and focus. Appreciated !
 
Upvote 0

Forum statistics

Threads
1,215,327
Messages
6,124,290
Members
449,149
Latest member
mwdbActuary

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