# Excel lookup using multiple cells

#### sobeitjedi

##### Board Regular
Hi.

I have one sheet which contains rows of travel data for multiple users for the week or so ahead. Some of the columns in this sheet are "name" "destination" "from date" "to date"

I have another sheet with similar data in, but it's larger and goes back many months/years.

What I want, is a formula I can put in a cell in the first sheet, which will look up data in the second sheet which matches the conditions for the 4 cells. Let me try to provide an example ...

Sheet1 has
name Destination from date to date
John.Smith London 11/11/2018 15/11/2018
Jane.Sinclair London 11/11/2018 15/11/2018

Sheet2 has
name Destination from date to date
John.Smith Tokyo 05/07/2017 15/08/2017
John.Smith London 11/11/2018 15/11/2018
Clive.Williams London 01/02/2018 15/02/2018
Jane.Sinclair London 07/01/2018 14/01/2018

If the four cells in Sheet 1 can lookup a match in Sheet 2 where all the conditions apply, then put a "yes" in the cell, if not a "no". In this example it would be a yes for John.Smith, but a no for Jane.Sinclair.

Hope that makes sense and someone can help!

Last edited:

### Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.

#### Special-K99

##### Well-known Member
One way

in Sheet1!E2
=IF(SUMPRODUCT((A2=Sheet2!A\$2:A\$1000)*(B2=Sheet2!B\$2:B\$1000)*(C2=Sheet2!C\$2:C\$1000)*(D2=Sheet2!D\$2:D\$1000))=1,"Yes","No")
and copy down the column

Last edited:

#### AlanY

##### Well-known Member
try this

<b>Note: Do not try and enter the {} manually yourself</b></td></tr></table><br />

#### Fluff

##### MrExcel MVP, Moderator
=IF(COUNTIFS(Sheet2!A:A,A2,Sheet2!B:B,B2,Sheet2!C:C,C2,Sheet2!D:D,D2)>0,"yes","no")

#### sobeitjedi

##### Board Regular
Whoa - thanks for all your quick help - that was fast work! Amazing.

A tweak is needed, when the from date is looked up, it needs to return a "yes" if the date is an approximate match (maybe 7 days either side) - is that possible?

Anyone?

#### Fluff

##### MrExcel MVP, Moderator
=IF(COUNTIFS(Sheet2!A:A,A2,Sheet2!B:B,B2,Sheet2!C:C,"<="&C2+7,Sheet2!C:C,">="&C2-7,Sheet2!D:D,D2)>0,"yes","no")

#### sobeitjedi

##### Board Regular
Absolutely fantastic. Thank you.

You're welcome

#### sobeitjedi

##### Board Regular
Hi. Have been using this formula over the past few months since my original post, which has been working an absolute treat - however, I need a small tweak, if you can help?

=IF(COUNTIFS(TA!B:B,H26,TA!E:E,N26,TA!D:D,"<="&K26+3,TA!D:D,">="&K26-3)>0,"yes","no")

What I would like, is when N26 is compared to column E in table TA, the data must be in the cell (using FIND maybe?).

For example, at the moment, N26 = London, but if the matching row in TA!E:E has "Paris (and London)" then it doesn't match as true at the moment, but I need it to?

Hope that makes sense!