# 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:

#### 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!

1,078,437
Messages
5,340,271
Members
399,361
Latest member
Linford

### This Week's Hot Topics

• Problem with Radio Button's format control
I am creating an employee evaluation template (a sample is below) Column A is the category Column B, C D, E and F will be ratings (unacceptable...
• Last Display on userform to a Listbox
[CODE=vba] lstdisplay.ColumnCount = 15 lstdisplay.RowSource = "A1:O600000" [/CODE] So when i do this it Displays everything on the sheet i am...
• Rename and move files to a new location
Dear all, I have an excel file with the following information. The actual file name is at column A but i want to rename it using the following...
• Help with True/False Formula
Hello! Am stumped how to fix this formula, in which my result returns 'True', but it should return False. =IF(AG2=True...
• Clear extra characters from a provided range of cells
Dear All, I have following code which gives me desired output to remove extra characters from a provided range. But it takes too much time when...
• Help with Current and highest streaks
Hi there, I've just joined the forum and this is my first post. I've already spent quite a bit of time searching the net and this forum for a...