Index Formula with IF

Rosadocc

New Member
Joined
Mar 15, 2012
Messages
49
Hi, I'm trying to set up a 1 column table (Table B) that looks up the unique values from another table (Table A).

Table A

[TABLE="width: 500"]
<tbody>[TR]
[TD]Company[/TD]
[TD]Contract[/TD]
[/TR]
[TR]
[TD]Apple
[/TD]
[TD]123[/TD]
[/TR]
[TR]
[TD]Google[/TD]
[TD]456[/TD]
[/TR]
[TR]
[TD]Samsung
[/TD]
[TD]789[/TD]
[/TR]
[TR]
[TD]Apple[/TD]
[TD]ABC[/TD]
[/TR]
[TR]
[TD]Samsung[/TD]
[TD]DEF[/TD]
[/TR]
[TR]
[TD]Samsung[/TD]
[TD]DEF[/TD]
[/TR]
</tbody>[/TABLE]

Table B
[TABLE="width: 500"]
<tbody>[TR]
[TD]Select Company[/TD]
[TD]Samsung[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]789[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]DEF[/TD]
[/TR]
</tbody>[/TABLE]

In the sample above the user will select on Table B a company from a data validated drop down (Samsung) and the unique contracts associated with Samsung will populate (789, and DEF). My current formula is populating DEF twice.
{=IFERROR(INDEX(ContractList,SMALL(IF(CompanyList='cell where Samsung is selected',ROW(ContractList)-ROW(B$2)+1),ROWS(ContractList))),)}

Any help is appreciated.
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
maybe something like...

Unknown[TABLE="class: grid, width: 400"]
<tbody>[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[TD]E[/TD]
[/TR]
[TR]
[TD="align: center"]1[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FAFAFA]#FAFAFA[/URL] "]Company[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FAFAFA]#FAFAFA[/URL] "]Contract[/TD]
[TD="align: right"][/TD]
[TD]Select Company[/TD]
[TD]samsung[/TD]
[/TR]
[TR]
[TD="align: center"]2[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FAFAFA]#FAFAFA[/URL] "]Apple[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FAFAFA]#FAFAFA[/URL] , align: right"]123[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"]789[/TD]
[/TR]
[TR]
[TD="align: center"]3[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FAFAFA]#FAFAFA[/URL] "]Google[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FAFAFA]#FAFAFA[/URL] , align: right"]456[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD]DEF[/TD]
[/TR]
[TR]
[TD="align: center"]4[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FAFAFA]#FAFAFA[/URL] "]Samsung[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FAFAFA]#FAFAFA[/URL] , align: right"]789[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="align: center"]5[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FAFAFA]#FAFAFA[/URL] "]Apple[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FAFAFA]#FAFAFA[/URL] "]ABC[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="align: center"]6[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FAFAFA]#FAFAFA[/URL] "]Samsung[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FAFAFA]#FAFAFA[/URL] "]DEF[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="align: center"]7[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FAFAFA]#FAFAFA[/URL] "]Samsung[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FAFAFA]#FAFAFA[/URL] "]DEF[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
Sheet1

[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] "]E2[/TH]
[TD="align: left"]{=IFERROR(INDEX($B$2:$B$7,SMALL(IF(FREQUENCY(IF($B$2:$B$7<>"",IF($A$2:$A$7=$E$1,MATCH($B$2:$B$7,$B$2:$B$7,0))),ROW($B$2:$B$7)-ROW($B$2)+1),ROW($B$2:$B$7)-ROW($B$2)+1),ROWS($E$2:E2))),"")}[/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]
 
Upvote 0
hi weazel, can you guide me on how to enter the table like to ones u did? especially the one with the formula?
also, would you know how people embed screenshots within a post? I have been trying forever!! Thanks
 
Upvote 0
maybe something like...

Unknown[TABLE="class: grid, width: 400"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[TD]E[/TD]
[/TR]
[TR]
[TD="align: center"]1[/TD]
[TD]Company[/TD]
[TD]Contract[/TD]
[TD="align: right"][/TD]
[TD]Select Company[/TD]
[TD]samsung[/TD]
[/TR]
[TR]
[TD="align: center"]2[/TD]
[TD]Apple[/TD]
[TD="align: right"]123[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"]789[/TD]
[/TR]
[TR]
[TD="align: center"]3[/TD]
[TD]Google[/TD]
[TD="align: right"]456[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD]DEF[/TD]
[/TR]
[TR]
[TD="align: center"]4[/TD]
[TD]Samsung[/TD]
[TD="align: right"]789[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="align: center"]5[/TD]
[TD]Apple[/TD]
[TD]ABC[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="align: center"]6[/TD]
[TD]Samsung[/TD]
[TD]DEF[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="align: center"]7[/TD]
[TD]Samsung[/TD]
[TD]DEF[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
Sheet1

[TABLE="width: 85%"]
<tbody>[TR]
[TD]Array Formulas[TABLE="width: 100%"]
<tbody>[TR]
[TH]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
[TR]
[TH]E2[/TH]
[TD="align: left"]{=IFERROR(INDEX($B$2:$B$7,SMALL(IF(FREQUENCY(IF($B$2:$B$7<>"",IF($A$2:$A$7=$E$1,MATCH($B$2:$B$7,$B$2:$B$7,0))),ROW($B$2:$B$7)-ROW($B$2)+1),ROW($B$2:$B$7)-ROW($B$2)+1),ROWS($E$2:E2))),"")}[/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]

Thanks Weazel! This worked great!
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,322
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