Select most recent occurrences using cells.Find

Jimmy509

New Member
Joined
Apr 18, 2019
Messages
29
Hi, I have this data:
UserID Date
1 03.22.2019
1 03.22.2018
2 03.22.2019
3 05.22.2018
3 05.22.2019

I would like to go through it using and select the user with the most recent occurrence.
I am using 2 worksheets. sheets(1) has the name of the user and I try to find the name in sheet(2) using "For each cell in sheet(1) in a range in sheet(2)". My problem is when the match happens. I want it to look at column B where the date is and pick the userID with the latest date.
Assume user ID is in sheet(1) column A. User ID is in sheet(2) Column A and Date is in Sheet(2) column B.
Please help as I am not sure how to do this in the most efficient way.
Here's my starter code:

For Each C in Rng
with Sheet(2).Cells
Set B = .FInd(C, LookIn:= xlValues, Lookat:= xlWhole)
If Not B Is Nothing Then
'Find the User ID. If there are multiple occurrences for userID. Find the one with the most recent date'
End IF
End With
Next
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Can anyone help please?
The format for sheet1 is:
UserID
1
1
2
3
3
The one for sheet2 is( as a correction from the post).
UserID Date
1 03.22.2019
1 03.22.2018
2 03.22.2019
3 05.22.2018
3 05.22.2019
 
Upvote 0
Sheet2:
Column A
UserID
1
1
2
3
3

Column B
Date
03.22.2019
03.22.2018
03.22.2019
05.22.2018
05.22.2019
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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