find a value in a column with duplicates and return first value

smgomez

Board Regular
Joined
Nov 13, 2009
Messages
65
I want to find the value in A1 in column F and return the corresponding date in column E in cell A2 as shown below. I am trying to avoid creating a lookup table and vlookup to do it. Column E and F have duplicates so I just need the date upon the first match of the value.

[TABLE="width: 448"]
<colgroup><col width="64" span="7" style="width:48pt"> </colgroup><tbody>[TR]
[TD="width: 64"][TABLE="width: 448"]
<colgroup><col width="64" span="7" style="width:48pt"> </colgroup><tbody>[TR]
[TD="class: xl66, width: 64"][/TD]
[TD="class: xl66, width: 64"]A[/TD]
[TD="class: xl66, width: 64"]B[/TD]
[TD="class: xl66, width: 64"]C[/TD]
[TD="class: xl66, width: 64"]D[/TD]
[TD="class: xl66, width: 64"]E[/TD]
[TD="class: xl66, width: 64"]F[/TD]
[/TR]
[TR]
[TD="class: xl66"]1[/TD]
[TD="class: xl67"]47.00[/TD]
[TD="class: xl67"]48.00[/TD]
[TD="class: xl67"]49.00[/TD]
[TD="class: xl66"][/TD]
[TD="class: xl66"]date[/TD]
[TD="class: xl66"]value[/TD]
[/TR]
[TR]
[TD="class: xl66"]2[/TD]
[TD="class: xl68"]1/1/2021[/TD]
[TD="class: xl68"]3/1/2018[/TD]
[TD="class: xl68"]5/1/2019[/TD]
[TD="class: xl66"][/TD]
[TD="class: xl68"]1/1/2021[/TD]
[TD="class: xl67"]47.00[/TD]
[/TR]
[TR]
[TD="class: xl66"]3[/TD]
[TD="class: xl69"][/TD]
[TD="class: xl69"][/TD]
[TD="class: xl69"][/TD]
[TD="class: xl68"][/TD]
[TD="class: xl68"]3/1/2018[/TD]
[TD="class: xl67"]48.00[/TD]
[/TR]
[TR]
[TD="class: xl66"]4[/TD]
[TD="class: xl66"][/TD]
[TD="class: xl66"][/TD]
[TD="class: xl66"][/TD]
[TD="class: xl66"][/TD]
[TD="class: xl68"]3/1/2018[/TD]
[TD="class: xl67"]48.00[/TD]
[/TR]
[TR]
[TD="class: xl66"]5[/TD]
[TD="class: xl66"][/TD]
[TD="class: xl66"][/TD]
[TD="class: xl66"][/TD]
[TD="class: xl66"][/TD]
[TD="class: xl68"]5/1/2019[/TD]
[TD="class: xl67"]49.00[/TD]
[/TR]
[TR]
[TD="class: xl66"]6[/TD]
[TD="class: xl66"][/TD]
[TD="class: xl66"][/TD]
[TD="class: xl66"][/TD]
[TD="class: xl66"][/TD]
[TD="class: xl68"]5/1/2019[/TD]
[TD="class: xl67"]49.00[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD="class: xl68, width: 64"][/TD]
[TD="class: xl68, width: 64"][/TD]
[TD="class: xl68, width: 64"][/TD]
[TD="class: xl68, width: 64"][/TD]
[TD="class: xl68, width: 64"][/TD]
[TD="class: xl68, width: 64"][/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
But you already have a lookup table and vlookup is the best solution here:


Excel 2010
ABCDEF
1474849datevalue
21/1/20213/1/20185/1/20191/1/202147
33/1/201848
43/1/201848
55/1/201949
65/1/201949
Sheet11
Cell Formulas
RangeFormula
A2=VLOOKUP(A1,CHOOSE({2,1},$E$2:$E$6,$F$2:$F$6),2,0)
 
Upvote 0
ok, let me add additional info. The info in columns E and F are in a separate worksheet and I need to include the entire column versus rows 2-6 in the example above which is oversimplified. I tried to adjust per your formula recommendation as follows but it did not work, the result is #N/A: =VLOOKUP(A$1,CHOOSE({2,1},Sheet2!$B:$B,Sheet2!$A:$A),2,0) what is the {2,1} accomplishing in this formula and please advise how to make it work when the data is not in a range on another sheet potentially somewhere in the entire column. Thanks!
 
Upvote 0
Don't use the entire column! That's over 1 million rows (or 65k+ in Excel 2003 and earlier) and very inefficient. If you actually have that much data Power BI is a far better approach. The formula looks up A1 in Sheet2!A:A and returns the adjacent value in Sheet2!B:B but be sure the range contains the same value--not the value with an extra space or stored as text while the other is a number.
 
Upvote 0
Try INDEX/MATCH

A2 copied across
=INDEX(Sheet1!$A:$A,MATCH(A$1,Sheet1!$B:$B,0))

M.
 
Upvote 0
=VLOOKUP(A$1,CHOOSE({2,1},Sheet2!$B:$B,Sheet2!$A:$A),2,0)

If Marcelo's formula works for you then this should also:

=VLOOKUP(A$1,CHOOSE({2,1},Sheet2!$A:$A,Sheet2!$B:$B),2,0)

(It was backwards. The choose array reverses the two columns for a left lookup effect)
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

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