finding corresponding values in an array

kpm30519

New Member
Joined
Nov 9, 2018
Messages
22
Hi--

I have a list of values in columns, organized by date. I'm trying to return the first instance of a specific value no matter the column it's in:

[TABLE="width: 312"]
<tbody>[TR]
[TD] Date[/TD]
[TD]Box1[/TD]
[TD]Box2[/TD]
[TD]Box3[/TD]
[TD]Box4[/TD]
[TD]Box5[/TD]
[/TR]
[TR]
[TD]10/31/17
[/TD]
[TD]31[/TD]
[TD]53[/TD]
[TD]6[/TD]
[TD]28[/TD]
[TD]52[/TD]
[/TR]
[TR]
[TD]11/03/17[/TD]
[TD]69[/TD]
[TD]10[/TD]
[TD]61[/TD]
[TD]42[/TD]
[TD]22[/TD]
[/TR]
[TR]
[TD]11/07/17[/TD]
[TD]1[/TD]
[TD]68[/TD]
[TD]69[/TD]
[TD]60[/TD]
[TD]54[/TD]
[/TR]
[TR]
[TD]11/10/17[/TD]
[TD]6[/TD]
[TD]38[/TD]
[TD]42[/TD]
[TD]23[/TD]
[TD]69[/TD]
[/TR]
</tbody>[/TABLE]

If I search for the value 69, my result should be 11/03/17 even though the value is in 3 columns.

Thanks for your help, I'm loosing my hair over this.
 
Last edited by a moderator:

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Is the date in column A if not what column
And what is Box1 and Box 2 etc.

I do not understand Box

Do you mean column B Column C

Excel has nothing named Box

And where do you want the results?
 
Upvote 0
Hi & welcome to MrExcel.
If you had this


Excel 2013/2016
CDEFGH
17DateBox1Box2Box3Box4Box5
1810/31/2017316962852
1911/03/20176910614222
2011/07/2017168696054
2111/10/2017638422369
List


Which would you consider to be the "first". The Blue one because of the row, or the green one because of the column?
 
Upvote 0
Assuming you want the earliest date


Excel 2013/2016
ABCDEFG
1DateBox1Box2Box3Box4Box569
210/31/201731696285210/31/2017
311/03/20176910614222
411/07/2017168676054
511/10/2017638422369
List
Cell Formulas
RangeFormula
G2{=INDEX(A2:A5,MIN(IF(B2:F5=G1,ROW(B2:F5)-1)))}
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
Assuming you want the earliest date

Excel 2013/2016
ABCDEFG
DateBox1Box2Box3Box4Box5
10/31/201710/31/2017

<tbody>
[TD="align: center"]1[/TD]

[TD="align: right"]69[/TD]

[TD="align: center"]2[/TD]

[TD="align: right"]31[/TD]
[TD="align: right"]69[/TD]
[TD="align: right"]6[/TD]
[TD="align: right"]28[/TD]
[TD="align: right"]52[/TD]

[TD="align: center"]3[/TD]
[TD="align: right"]11/03/2017[/TD]
[TD="align: right"]69[/TD]
[TD="align: right"]10[/TD]
[TD="align: right"]61[/TD]
[TD="align: right"]42[/TD]
[TD="align: right"]22[/TD]
[TD="align: right"][/TD]

[TD="align: center"]4[/TD]
[TD="align: right"]11/07/2017[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]68[/TD]
[TD="align: right"]67[/TD]
[TD="align: right"]60[/TD]
[TD="align: right"]54[/TD]
[TD="align: right"][/TD]

[TD="align: center"]5[/TD]
[TD="align: right"]11/10/2017[/TD]
[TD="align: right"]6[/TD]
[TD="align: right"]38[/TD]
[TD="align: right"]42[/TD]
[TD="align: right"]23[/TD]
[TD="align: right"]69[/TD]
[TD="align: right"][/TD]

</tbody>
List

[TABLE="width: 85%"]
<tbody>[TR]
[TD]Array Formulas[TABLE="width: 100%"]
<tbody>[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]
[TH]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
[TR]
[TH="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]G2[/TH]
[TD="align: left"]{=INDEX(A2:A5,MIN(IF(B2:F5=G1,ROW(B2:F5)-1)))}[/TD]
[/TR]
</tbody>[/TABLE]
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself[/TD]
[/TR]
</tbody>[/TABLE]
THANK YOU FLUFF!!!

It was very late when I posted, and I noticed I made some small mistakes, but with your help I was able to use "=INDEX(C$2:C$1048576,MAX(IF(D$2:H$1048576=AE2,ROW(D$2:H$1048576)-1)))." I realized my dates were in reverse order, so I used MAX, and it's PERFECT!!

Thanks Again!
 
Upvote 0
Glad to help & thanks for the feedback.
I would however recommend you reduce the size of the arrays, running an array formula on entire columns tends to be very slow.
 
Upvote 0

Forum statistics

Threads
1,224,822
Messages
6,181,165
Members
453,021
Latest member
Justyna P

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