Excel lookup using multiple cells

sobeitjedi

Board Regular
Joined
Mar 13, 2006
Messages
179
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
Joined
Nov 7, 2006
Messages
8,302
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
Joined
Oct 30, 2014
Messages
3,826
try this

<b></b><table cellpadding="2.5px" rules="all" style=";background-color: rgb(255,255,255);border: 1px solid;border-collapse: collapse; border-color: rgb(187,187,187)"><colgroup><col width="25px" style="background-color: rgb(218,231,245)" /><col /><col /><col /><col /><col /><col /><col /><col /><col /><col /><col /><col /></colgroup><thead><tr style=" background-color: rgb(218,231,245);text-align: center;color: rgb(22,17,32)"><th></th><th>A</th><th>B</th><th>C</th><th>D</th><th>E</th><th>F</th><th>G</th><th>H</th><th>I</th><th>J</th><th>K</th><th>L</th></tr></thead><tbody><tr ><td style="color: rgb(22,17,32);text-align: center;">1</td><td style=";">name</td><td style=";">Destination</td><td style=";">from</td><td style=";">to</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style=";">name</td><td style=";">Destination</td><td style=";">from</td><td style=";">to</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">2</td><td style=";">John.Smith</td><td style=";">London</td><td style="text-align: right;;">11/11/2018</td><td style="text-align: right;;">15/11/2018</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style=";">John.Smith</td><td style=";">Tokyo</td><td style="text-align: right;;">05/07/2017</td><td style="text-align: right;;">15/08/2017</td><td style="text-align: right;;"></td><td style="background-color: #E2EFDA;;">no</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">3</td><td style=";">Jane.Sinclair</td><td style=";">London</td><td style="text-align: right;;">11/11/2018</td><td style="text-align: right;;">15/11/2018</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style=";">John.Smith</td><td style=";">London</td><td style="text-align: right;;">11/11/2018</td><td style="text-align: right;;">15/11/2018</td><td style="text-align: right;;"></td><td style="background-color: #E2EFDA;;">yes</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">4</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style=";">Clive.Williams</td><td style=";">London</td><td style="text-align: right;;">01/02/2018</td><td style="text-align: right;;">15/02/2018</td><td style="text-align: right;;"></td><td style="background-color: #E2EFDA;;">no</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">5</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style=";">Jane.Sinclair</td><td style=";">London</td><td style="text-align: right;;">07/01/2018</td><td style="text-align: right;;">14/01/2018</td><td style="text-align: right;;"></td><td style="background-color: #E2EFDA;;">no</td></tr></tbody></table><p style="width:4.8em;font-weight:bold;margin:0;padding:0.2em 0.6em 0.2em 0.5em;border: 1px solid rgb(187,187,187);border-top:none;text-align: center;background-color: rgb(218,231,245);color: rgb(22,17,32)">Sheet1</p><br /><br /><table width="85%" cellpadding="2.5px" rules="all" style=";border: 2px solid black;border-collapse:collapse;padding: 0.4em;background-color: rgb(255,255,255)" ><tr><td style="padding:6px" ><b>Array Formulas</b><table cellpadding="2.5px" width="100%" rules="all" style="border: 1px solid;text-align:center;background-color: rgb(255,255,255);border-collapse: collapse; border-color: rgb(187,187,187)"><thead><tr style=" background-color: rgb(218,231,245);color: rgb(22,17,32)"><th width="10px">Cell</th><th style="text-align:left;padding-left:5px;">Formula</th></tr></thead><tbody><tr><th width="10px" style=" background-color: rgb(218,231,245);color: rgb(22,17,32)">L2</th><td style="text-align:left">{=IF(<font color="Blue">ISNUMBER(<font color="Red">MATCH(<font color="Green">G2&H2&I2&J2,$A$2:$A$10&$B$2:$B$10&$C$2:$C$10&$D$2:$D$10,0</font>)</font>),"yes","no"</font>)}</td></tr></tbody></table><b>Entered with Ctrl+Shift+Enter.</b> If entered correctly, Excel will surround with curly braces {}.
<b>Note: Do not try and enter the {} manually yourself</b></td></tr></table><br />
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
30,301
Office Version
365
Platform
Windows
How about
=IF(COUNTIFS(Sheet2!A:A,A2,Sheet2!B:B,B2,Sheet2!C:C,C2,Sheet2!D:D,D2)>0,"yes","no")
 

sobeitjedi

Board Regular
Joined
Mar 13, 2006
Messages
179
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?
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
30,301
Office Version
365
Platform
Windows
How about
=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")
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
30,301
Office Version
365
Platform
Windows
You're welcome
 

sobeitjedi

Board Regular
Joined
Mar 13, 2006
Messages
179
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!
 

Forum statistics

Threads
1,077,959
Messages
5,337,421
Members
399,145
Latest member
SPLhorses

Some videos you may like

This Week's Hot Topics

Top