Complex lookup

horrellbt01

Board Regular
Joined
Mar 15, 2010
Messages
68
I am trying to figure out a rather complex lookup.

Here is an example set of data.


A B C D E F

1

2

3

4 X

5 2 3


What i need to do is the following:

If there is an X in Range B3:F5, then I want to return whatever is in column A of that same row and row one of the same column.
So in my example above, there is an X in D4. I would want to return the value of A4 in one cell, and D1 in another. So probably looking at 2 different formulas.

Thought maybe INDEX and MATCH would work, but so far have not been able to work it out.
 
Last edited:

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
How about


Book1
ABCDEFGH
1ABCDEF
21ColumnD
32Row4
43
54X
Norfolk
Cell Formulas
RangeFormula
H2=INDEX($B$1:$F$1,AGGREGATE(15,6,(COLUMN($A$2:$F$2)-COLUMN($A$2)+1)/($B$2:$F$5="X"),1))
H3=INDEX($A$2:$A$5,AGGREGATE(15,6,(ROW($A$2:$A$5)-ROW($A$2)+1)/($B$2:$F$5="X"),1))
 
Upvote 0
open
open
Using the attached image.
Since there an X in G3, I would want A3 in J2, and G1 in K2
Next X would be in C4. So I would want the value of A4 in J3 and C1 in K3.
Then keep going with the X's in D4 and F7, etc.

open
[TABLE="class: grid, width: 800"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[TD]E[/TD]
[TD]F[/TD]
[TD]G[/TD]
[TD]H[/TD]
[TD]I[/TD]
[TD]J[/TD]
[TD]K[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD][/TD]
[TD][/TD]
[TD]Result 2[/TD]
[TD]Result 2[/TD]
[TD]Result 2[/TD]
[TD]Result 2[/TD]
[TD]Result 2[/TD]
[TD][/TD]
[TD][/TD]
[TD]List of Result 1[/TD]
[TD]List of Result 2[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]Result 1[/TD]
[TD][/TD]
[TD]1[/TD]
[TD]3[/TD]
[TD]7[/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D]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]11[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]12[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
 
Last edited:
Upvote 0
To return column header

=INDEX(B1:F1,MAX(IF(B3:F5="X",COLUMN(B1:F1)-COLUMN(B1)+1)))
Array formula, use Ctrl-Shift-Enter

To return row header

=INDEX(A3:A5,MAX(IF(B3:F5="X",ROW(A3:A5)-ROW(A3)+1)))
Array formula, use Ctrl-Shift-Enter

UPDATE: My solution does not allow for duplicate Xs in the grid
 
Last edited:
Upvote 0
Try this

<table border="1" cellspacing="0" style="font-family:Calibri,Arial; font-size:11pt; background-color:#ffffff; "> <colgroup><col style="font-weight:bold; width:30px; " /><col style="width:107.41px;" /><col style="width:26.61px;" /><col style="width:67.49px;" /><col style="width:67.49px;" /><col style="width:67.49px;" /><col style="width:67.49px;" /><col style="width:67.49px;" /><col style="width:23.76px;" /><col style="width:23.76px;" /><col style="width:141.62px;" /><col style="width:104.55px;" /></colgroup><tr style="background-color:#cacaca; text-align:center; font-weight:bold; font-size:8pt; "><td > </td><td >A</td><td >B</td><td >C</td><td >D</td><td >E</td><td >F</td><td >G</td><td >H</td><td >I</td><td >J</td><td >K</td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >1</td><td > </td><td > </td><td >Result 2 -1</td><td >Result 2 -2</td><td >Result 2 -3</td><td >Result 2 -4</td><td >Result 2 -5</td><td > </td><td > </td><td >List of Result 1</td><td >List of Result 2</td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >2</td><td >Result 1 - 1</td><td > </td><td style="text-align:center; ">1</td><td style="text-align:center; ">3</td><td style="text-align:center; ">7</td><td style="text-align:center; ">9</td><td style="text-align:center; ">2</td><td > </td><td > </td><td >Result 1 - 2</td><td >Result 2 -1</td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >3</td><td >Result 1 - 2</td><td > </td><td style="text-align:center; ">0</td><td style="text-align:center; ">0</td><td style="text-align:center; ">3</td><td style="text-align:center; ">2</td><td style="text-align:center; ">X</td><td > </td><td > </td><td >Result 1 - 3</td><td >Result 2 -2</td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >4</td><td >Result 1 - 3</td><td > </td><td style="text-align:center; ">X</td><td style="text-align:center; ">X</td><td style="text-align:center; ">1</td><td style="text-align:center; ">5</td><td style="text-align:center; ">8</td><td > </td><td > </td><td >Result 1 - 3</td><td >Result 2 -4</td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >5</td><td >Result 1 - 4</td><td > </td><td style="text-align:center; ">6</td><td style="text-align:center; ">0</td><td style="text-align:center; ">0</td><td style="text-align:center; ">6</td><td style="text-align:center; ">5</td><td > </td><td > </td><td >Result 1 - 5</td><td >Result 2 -5</td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >6</td><td >Result 1 - 5</td><td > </td><td style="text-align:center; ">0</td><td style="text-align:center; ">1</td><td style="text-align:center; ">8</td><td style="text-align:center; ">X</td><td style="text-align:center; ">7</td><td > </td><td > </td><td > </td><td > </td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >7</td><td > </td><td > </td><td > </td><td > </td><td > </td><td > </td><td > </td><td > </td><td > </td><td > </td><td > </td></tr></table><br /><table style="font-family:Arial; font-size:10pt; border-style: groove ;border-color:#00ff00;background-color:#fffcf9; color:#000000; "><tr><td ><b></b></td></tr><tr><td ><table border = "1" cellspacing="0" cellpadding="2" style="font-family:Arial; font-size:9pt;"><tr style="background-color:#cacaca; font-size:10pt;"><td >Cell</td><td >Array Formula</td></tr><tr><td >J2</td><td >{=IFERROR(INDEX($A$1:$A$6,SMALL(IF($C$2:$G$6="X",ROW($B$2:$B$6)),ROWS($I$2:I2))),"")}</td></tr><tr><td >K2</td><td >{=IFERROR(INDEX($A$1:$G$1,0,SMALL(IF($C$2:$G$6="X",COLUMN($C$1:$G$1)),ROWS($I$2:J2))),"")}</td></tr></table></td></tr></table>

Array formulas
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself


Put the formulas in J2 and K2, then copy down.
 
Upvote 0
That is really close, but the Result 2 formula looks like it is off just a little bit.

The List of Results should be the following based on the chart below.

[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]List of Result 1[/TD]
[TD]List of Result 2[/TD]
[/TR]
[TR]
[TD]Result 1-2[/TD]
[TD]Result 2-5[/TD]
[/TR]
[TR]
[TD]Result 1-3[/TD]
[TD]Result 2-1[/TD]
[/TR]
[TR]
[TD]Result 1-3[/TD]
[TD]Result 2-2[/TD]
[/TR]
[TR]
[TD]Result 1-5[/TD]
[TD]Result 2-4[/TD]
[/TR]
</tbody>[/TABLE]



Try this

ABCDEFGHIJK
Result 2 -1Result 2 -2Result 2 -3Result 2 -4Result 2 -5List of Result 1List of Result 2
Result 1 - 1Result 1 - 2Result 2 -1
Result 1 - 2Result 1 - 3Result 2 -2
Result 1 - 3Result 1 - 3Result 2 -4
Result 1 - 4Result 1 - 5Result 2 -5
Result 1 - 5

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

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

[TD="align: center"]1[/TD]
[TD="align: center"]3[/TD]
[TD="align: center"]7[/TD]
[TD="align: center"]9[/TD]
[TD="align: center"]2[/TD]

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

[TD="align: center"]0[/TD]
[TD="align: center"]0[/TD]
[TD="align: center"]3[/TD]
[TD="align: center"]2[/TD]
[TD="align: center"]X[/TD]

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

[TD="align: center"]X[/TD]
[TD="align: center"]X[/TD]
[TD="align: center"]1[/TD]
[TD="align: center"]5[/TD]
[TD="align: center"]8[/TD]

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

[TD="align: center"]6[/TD]
[TD="align: center"]0[/TD]
[TD="align: center"]0[/TD]
[TD="align: center"]6[/TD]
[TD="align: center"]5[/TD]

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

[TD="align: center"]0[/TD]
[TD="align: center"]1[/TD]
[TD="align: center"]8[/TD]
[TD="align: center"]X[/TD]
[TD="align: center"]7[/TD]

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

</tbody>

CellArray Formula
J2{=IFERROR(INDEX($A$1:$A$6,SMALL(IF($C$2:$G$6="X",ROW($B$2:$B$6)),ROWS($I$2:I2))),"")}
K2{=IFERROR(INDEX($A$1:$G$1,0,SMALL(IF($C$2:$G$6="X",COLUMN($C$1:$G$1)),ROWS($I$2:J2))),"")}

<tbody>
</tbody>

<tbody>
</tbody>


Array formulas
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself


Put the formulas in J2 and K2, then copy down.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,885
Messages
6,175,184
Members
452,615
Latest member
bogeys2birdies

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