Complex lookup

horrellbt01

Board Regular
Joined
Mar 15, 2010
Messages
65
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

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
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
ABCDEFGHIJK
1Result 2Result 2Result 2Result 2Result 2List of Result 1List of Result 2
2Result 113792
3Result 10032X
4Result 1XX158
5Result 160065
6Result 1018X7
7
8
9
10
11
12

<tbody>
</tbody>
 
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.

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

<tbody>
</tbody>



Try this

ABCDEFGHIJK
1Result 2 -1Result 2 -2Result 2 -3Result 2 -4Result 2 -5List of Result 1List of Result 2
2Result 1 - 113792Result 1 - 2Result 2 -1
3Result 1 - 20032XResult 1 - 3Result 2 -2
4Result 1 - 3XX158Result 1 - 3Result 2 -4
5Result 1 - 460065Result 1 - 5Result 2 -5
6Result 1 - 5018X7
7

<tbody>
</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,214,523
Messages
6,120,028
Members
448,940
Latest member
mdusw

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