How to check whether multiple criteria exist within the same row of an array?

a_faulding

New Member
Joined
Jul 14, 2020
Messages
8
Office Version
  1. 365
Hello,

I work in travel, and I want to check whether certain routes exist in a data set.

The routes have a departure and destination values. The destination values are countries, regions or resorts:

DepartureDestination
BirminghamSpain
EdinburghCosta Blanca
BelfastBudapest

The data set shows all possible countries, regions and resorts that can be visited from any departure location:

Departure LocationDestination CountryDestination RegionDestination Resort
BirminghamSpainLanzarote
EdinburghSpainAlicanteCosta Blanca
BelfastHungaryBudapest

The logic I need to use to see whether a route is in the data set, is: "Does the Departure and Destination value exist within the same row of the data set array".

I have been able to get this to work with an array index match formula, but the limitation of this is that I have had to specify individual columns in the lookup array. For example columns A:A and B:B in the example below:

{=INDEX(A:A,MATCH("Birmingham"&"Spain",A:A&B:B,0))}

The challenge I have here, is that the table is pretty huge - with many region and resort columns. So ideally I need a means of checking the entire data set array, rather than only checking two columns at a time.

Any help appreciated!

Andrew
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Have you considered using a macro? What do you want to do if the Departure and Destination value exist within the same row of the data and what do you want to do if it doesn't?
 
Upvote 0
I have not considered a macro, no. It's been a long time since I've had a go at one, but I am certainly happy to hear any suggestions anyone may have.

Just to improve clarity here, the three routes shown in the first table would all match with rows in the data table based on my logic. But if Birmingham > Budapest was a route I wanted to check, it would not match because Birmingham and Budapest do not exist in the same row of the data set (even though they do exist in different columns).

As long as I can identify the matches, the output doesn't really matter. TRUE/FALSE or similar would be fine.
 
Upvote 0
Hi & welcome to MrExcel.
Two options, depending on whether you have the Filter function.
+Fluff New.xlsm
ABCD
1Departure LocationDestination CountryDestination RegionDestination Resort
2BirminghamSpainLanzarote
3EdinburghSpainAlicanteCosta Blanca
4BelfastHungaryBudapest
5
6
7
8
9
10DepartureDestinationFilterIndex
11BirminghamSpainTRUETRUE
12EdinburghCosta BlancaTRUETRUE
13BelfastBudapestTRUETRUE
14EdinburghLanzaroteFALSEFALSE
Main
Cell Formulas
RangeFormula
C11:C14C11=ISNUMBER(SEARCH(B11,TEXTJOIN(",",,FILTER($B$2:$D$4,$A$2:$A$4=A11))))
D11:D14D11=ISNUMBER(SEARCH(B11,TEXTJOIN(,,INDEX($B$2:$D$4,MATCH(A11,$A$2:$A$4,0),COLUMN(A1:C1)))))
 
Upvote 0
It looks like Fluff has given you a solution.
 
Upvote 0
Thanks for the response. Unfortunately I don't have the FILTER function, and I don't think the index match is quite there.

It works in the example above, but comes unstuck when departure locations appear on multiple occasions throughout the sheet.

I believe this is because the indexed cell is determined by the first row that is matched.

For example, if I want to check whether the Belfast > Lanzarote route exists in the table below, the suggested index match formula returns FALSE:

Departure LocationDestination CountryDestination RegionDestination Resort
BirminghamSpainLanzarote
EdinburghSpainAlicanteCosta Blanca
BelfastHungaryBudapest
BelfastSpainLanzarote
 
Upvote 0
In that case how about
+Fluff New.xlsm
ABCD
1Departure LocationDestination CountryDestination RegionDestination Resort
2BirminghamSpainLanzarote
3EdinburghSpainAlicanteCosta Blanca
4BelfastHungaryBudapest
5BelfastSpainLanzarote
6
7
8
9
10DepartureDestination
11BirminghamSpainTRUE
12EdinburghCosta BlancaTRUE
13BelfastLanzaroteTRUE
14EdinburghLanzaroteFALSE
Main
Cell Formulas
RangeFormula
C11:C14C11=ISNUMBER(SEARCH(B11,TEXTJOIN(,,INDEX($B$2:$D$5,AGGREGATE(15,6,(ROW($B$2:$B$5)-ROW($B$2)+1)/($A$2:$A$5=A11),COUNTIF($A$2:$A$5,A11)),COLUMN(A1:C1)))))
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,215,043
Messages
6,122,822
Members
449,096
Latest member
Erald

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