Formula Locating Common Value

ReaperX

New Member
Joined
Oct 25, 2012
Messages
12
Hello,

I have a table with two columns of airports. Column 1 is the originating, and column 2 is the destination. Each airport is listed multiple times in each column. I have a formula that can find if a direct flight is possible, but I am looking for a formula that can find connections. As an example, I know Madison flies to Chicago, and I know Chicago flies to Little Rock. How can I find that Chicago is the connecting flight between Madison and Little Rock? I know some of these will have multiple connections, which I can try and figure out, but at least the first possible one should populate.

My data is set up as follows:
[TABLE="class: grid, width: 500"]
<TBODY>[TR]
[TD]Origin[/TD]
[TD]Destination[/TD]
[/TR]
[TR]
[TD]MADISON[/TD]
[TD]LAS VEGAS[/TD]
[/TR]
[TR]
[TD]MADISON[/TD]
[TD]CHICAGO[/TD]
[/TR]
[TR]
[TD]MADISON[/TD]
[TD]ATLANTA[/TD]
[/TR]
[TR]
[TD]MADISON[/TD]
[TD]BOSTON[/TD]
[/TR]
[TR]
[TD]CHICAGO[/TD]
[TD]MADISON[/TD]
[/TR]
[TR]
[TD]CHICAGO[/TD]
[TD]LITTLE ROCK[/TD]
[/TR]
[TR]
[TD]CHICAGO[/TD]
[TD]PHOENIX[/TD]
[/TR]
[TR]
[TD]LITTLE ROCK[/TD]
[TD]SEATTLE[/TD]
[/TR]
[TR]
[TD]LITTLE ROCK[/TD]
[TD]CHICAGO[/TD]
[/TR]
</TBODY>[/TABLE]

Any help is appreciated.
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Hello,

I have a table with two columns of airports. Column 1 is the originating, and column 2 is the destination. Each airport is listed multiple times in each column. I have a formula that can find if a direct flight is possible, but I am looking for a formula that can find connections. As an example, I know Madison flies to Chicago, and I know Chicago flies to Little Rock. How can I find that Chicago is the connecting flight between Madison and Little Rock? I know some of these will have multiple connections, which I can try and figure out, but at least the first possible one should populate.

My data is set up as follows:
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Origin[/TD]
[TD]Destination[/TD]
[/TR]
[TR]
[TD]MADISON[/TD]
[TD]LAS VEGAS[/TD]
[/TR]
[TR]
[TD]MADISON[/TD]
[TD]CHICAGO[/TD]
[/TR]
[TR]
[TD]MADISON[/TD]
[TD]ATLANTA[/TD]
[/TR]
[TR]
[TD]MADISON[/TD]
[TD]BOSTON[/TD]
[/TR]
[TR]
[TD]CHICAGO[/TD]
[TD]MADISON[/TD]
[/TR]
[TR]
[TD]CHICAGO[/TD]
[TD]LITTLE ROCK[/TD]
[/TR]
[TR]
[TD]CHICAGO[/TD]
[TD]PHOENIX[/TD]
[/TR]
[TR]
[TD]LITTLE ROCK[/TD]
[TD]SEATTLE[/TD]
[/TR]
[TR]
[TD]LITTLE ROCK[/TD]
[TD]CHICAGO[/TD]
[/TR]
</tbody>[/TABLE]

Any help is appreciated.

Is this a finite list of desitantion or you have more and more...
What answer do you expect for each of the line?
 
Upvote 0
The list is much longer and could change. The results are not part of that table at all. I have two dropdowns that allow me to choose departure airport and destination airport. When they don't have direct flights, I would like a cell to return a common flight. All of the flights in the list are reversible (i.e. Little Rock to Seattle is also Seattle to Little Rock). If it can populate a list of ALL common flights, that would be great too, but I really just need the first one that comes up.
 
Upvote 0
Hi,

If I follow, try this...

Set up:

*ABCDEF
OriginDestination*OriginDestinationConnecting Flights
MADISONLAS VEGAS*MADISONLITTLE ROCKCHICAGO
MADISONCHICAGO*MADISONLITTLE ROCKLAS VEGAS
MADISONATLANTA****
MADISONBOSTON****
CHICAGOMADISON****
CHICAGOLITTLE ROCK****
CHICAGOPHOENIX****
LITTLE ROCKSEATTLE****
LAS VEGASLITTLE ROCK****

<tbody>
[TD="bgcolor: #cacaca, align: center"]1[/TD]

[TD="bgcolor: #cacaca, align: center"]2[/TD]

[TD="bgcolor: #cacaca, align: center"]3[/TD]

[TD="bgcolor: #cacaca, align: center"]4[/TD]

[TD="bgcolor: #cacaca, align: center"]5[/TD]

[TD="bgcolor: #cacaca, align: center"]6[/TD]

[TD="bgcolor: #cacaca, align: center"]7[/TD]

[TD="bgcolor: #cacaca, align: center"]8[/TD]

[TD="bgcolor: #cacaca, align: center"]9[/TD]

[TD="bgcolor: #cacaca, align: center"]10[/TD]

</tbody>

Array formula in F2 is:

Code:
=INDEX(B$2:B$10,MATCH(1,IF(A$2:A$10=D2,IF(B$2:B$10=INDEX(A$2:A$10,SMALL(IF(B$2:B$10=E2,ROW(B$2:B$10)-ROW(B$2)+1),ROWS(F$2:F2))),1)),0))

Which requires entry with CTRL+SHIFT+ENTER and can then be copied down...

Does it do as desired?

Matty
 
Upvote 0

Forum statistics

Threads
1,223,634
Messages
6,173,475
Members
452,516
Latest member
archcalx

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