Vlookup & match

amyylouise

New Member
Joined
Sep 3, 2013
Messages
22
CUSTOMERS TABLE


CONTACTS TABLE


WHAT I WANT TO DO:

In the CONTACTS TABLE when the Company and Branch entered is the same as the Company and Branch in the CUSTOMERS TABLE - pull the Account, Address, City, Province, Postal Code, and Country from the CUSTOMERS TABLE and enter this information in the respective cells in the CONTACTS TABLE

Help Please! I'm not sure which formula I should be using for this. Maybe VLOOKUP & MATCH???
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

cyrilbrd

Well-known Member
Joined
Feb 2, 2012
Messages
4,095
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
Hi, will you use data validation in column B and C?
Given in sheet custable:
accountcompanybranchphonefaxcity
204ABCthis269-555-3182266-555-2030here
66077ABCthat215-555-3330304-555-3363there
3951BCDthis239-555-3373305-555-2631else
35890BCDthat240-555-2688274-555-1622what
36949DEFthat220-555-1334244-555-3272where

<colgroup><col span="3"><col span="2"><col></colgroup><tbody>
</tbody>

and in sheet customer:
accountcompanybranchphonefaxcity
66077ABCthat215-555-3330304-555-3363there

<colgroup><col><col><col><col span="2"><col></colgroup><tbody>
</tbody>
formula in a2 is =IFERROR(INDEX(custtable!A$2:A$6,MATCH(1,(custtable!$B$2:$B$6=$B2)*(custtable!$C$2:$C$6=$C2),0)),"") Ctrl + Shift + Enter not just Enter on a PC or Command + Return on a MAC copied to column D, E, F...

Would that work for you?
Adjust range and sheet name to fit your model.
 
Upvote 0

Aladin Akyurek

MrExcel MVP
Joined
Feb 14, 2002
Messages
85,210
CONTACTS

O2, control+shift+enter, not just enter, and copy down:
Rich (BB code):
=IFERROR(MATCH($B2,IF(CUSTOMERS!$C$2:$C$6=$C2,CUSTOMERS!$B$2:$B$6),0),"")

A2, just enter and copy down:
Rich (BB code):
=IF($O2="","",INDEX(CUSTOMERS!$A$2:$J$6,$O2,MATCH(A$1,CUSTOMERS!$A$1:$J$6,0)))

D2, copy across and down:
Rich (BB code):
=IF($O2="","",INDEX(CUSTOMERS!$A$2:$J$6,$O2,MATCH(D$1,CUSTOMERS!$A$1:$J$6,0)))
 
Upvote 0

cyrilbrd

Well-known Member
Joined
Feb 2, 2012
Messages
4,095
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
CONTACTS
...A2, just enter and copy down:
Rich (BB code):
=IF($O2="","",INDEX(CUSTOMERS!$A$2:$J$6,$O2,MATCH(A$1,CUSTOMERS!$A$1:$J$6,0)))
...
I might (most likely) be wrong but shouldn't it be =IF($O2="","",INDEX(CUSTOMERS!$A$2:$J$6,$O2,MATCH(A$1,CUSTOMERS!$A$1:$J$1,0)))? same for D2...
 
Upvote 0

Aladin Akyurek

MrExcel MVP
Joined
Feb 14, 2002
Messages
85,210
ADVERTISEMENT
I might (most likely) be wrong but shouldn't it be =IF($O2="","",INDEX(CUSTOMERS!$A$2:$J$6,$O2,MATCH(A$1,CUSTOMERS!$A$1:$J$1,0)))? same for D2...

Thanks for the catch. That's what was intended.
 
Upvote 0

cyrilbrd

Well-known Member
Joined
Feb 2, 2012
Messages
4,095
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
=IF($O2="","",INDEX(CUSTOMERS!$A$2:$J$6,$O2,MATCH(A$1,CUSTOMERS!$A$1:$J$1,0)))
Is this is more efficient correct and robust as compared with Index,Match(1,2cdts? it however requires one helper column but otherwise it would be better?
 
Upvote 0

Aladin Akyurek

MrExcel MVP
Joined
Feb 14, 2002
Messages
85,210
ADVERTISEMENT
Is this is more efficient correct and robust as compared with Index,Match(1,2cdts? it however requires one helper column but otherwise it would be better?

We would not want so many multiconditional Index/Match formulas. Hence the relative row calcs in column O. Yes, as such this is far more efficient.
 
Upvote 0

cyrilbrd

Well-known Member
Joined
Feb 2, 2012
Messages
4,095
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
I find this very interesting. Although the model of the OP would not call for duplicates, what would you recommend to return the rows of all that would fit if there were more than one row fitting the description(s).
What about for unique search, would something like CSE =IFERROR(SMALL(IF($B$2=Sheet2!$B$2:$B$6,ROW(Sheet2!$B$2:$B$6)-ROW(Sheet2!$B$2)+1),ROWS($O$2:O2)),"") be efficient?
Here we would look for ABC solely but this would return row 2 and row 3...
My concern is for two (2) search ABC and this assuming that this combination appears more than once:
accountcompanybranchphonefaxcity
204ABCthis269-555-3182266-555-2030here
66077ABCthis215-555-3330304-555-3363there
3951BCDthis239-555-3373305-555-2631else
35890ABCthis240-555-2688274-555-1622what
36949DEFthat220-555-1334244-555-3272where

<colgroup><col span="3"><col span="2"><col></colgroup><tbody>
</tbody>
 
Upvote 0

cyrilbrd

Well-known Member
Joined
Feb 2, 2012
Messages
4,095
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
what about =IFERROR(SMALL(IF($A$15=$A$2:$A$6,IF($B$15=$B$2:$B$6,ROW($A$2:$A$6)-ROW($A$2)+1)),ROWS($H15:H$15)),"")?
 
Upvote 0

Aladin Akyurek

MrExcel MVP
Joined
Feb 14, 2002
Messages
85,210
I'd just stay with multiconditional MATCH... The task appears to be a multifield single record retrieval, not a (multifield) multirecord retrieval.
 
Upvote 0

Forum statistics

Threads
1,195,582
Messages
6,010,577
Members
441,557
Latest member
Jbest23

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
Top