Return Code for a certain ID in a date Range

murrolems

New Member
Joined
Jun 5, 2024
Messages
7
Office Version
  1. 365
Platform
  1. Windows
I have the following data in 3 columns: ID, date and code. I need a formula that will return the code for a given ID and a random date that falls within a range. The date field could be sorted by ID first then date if necessary.

Table:
IDDateCode
1​
5/23/2024​
F
1​
5/8/2024​
E
1​
4/29/2024​
C
3​
5/23/2024​
S
3​
5/23/2024​
H
2​
5/8/2024​
E
2​
4/23/2024​
K
2​
5/23/2024​
X
4​
5/8/2024​
P

Here's an example of the desired output:

IDrandom datereturned code
1​
5/7/2024​
C
1​
5/8/2024​
E
1​
5/9/2024​
E
 
That means your columns A and E are not the same but they appear to be the same.
Try =E2=A2 I suspect this will return FALSE.
 
Upvote 0

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Changing match mode to 1 will give you wrong results for the others.
Book1 (version 1).xlsb
ABCDEFG
1IDDateCodeIDrandom datereturned code
215/23/2024F14/7/2024C
315/8/2024E15/8/2024C
414/29/2024C15/9/2024C
535/23/2024S
635/23/2024H
725/8/2024E
824/23/2024K
925/23/2024X
1045/8/2024P
Sheet2
Cell Formulas
RangeFormula
G2:G4G2=XLOOKUP(F2,IF($A$2:$A$10=E2,$B$2:$B$10),$C$2:$C$10,,1)
 
Upvote 0

Forum statistics

Threads
1,223,895
Messages
6,175,257
Members
452,625
Latest member
saadat28

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