Vlookup return value only if...

sgalligan

New Member
Joined
Jun 17, 2022
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hi all,

I've been searching the internet for a solution to this but due to the key words the only solutions I'm seeing do not pertain to this situation.

I'm basically trying to aggregate a bunch of data and I want to pull unit information from one set of data into my existing set of data so I have all the information I need in one spot. The common denominators in each set of data are product codes and countries.

I have two data sets--lets call them data set 1 and data set 2. I'm trying to vlookup a product code from data set 1 to pull in a value from data set 2 but ONLY if the country values match. I'm trying to avoid creating another column to combine product code and country into one cell just for the vlookup so hoping there is a catch-all formula that can do that for me. Any ideas are appreciated!

I've stated the value in RED in data set 1 below.

DATA SET 1:
CODEMEXICOAUSTRALIA
123Vlookup product code 123 to pull in "UNITS" value ONLY if country is MexicoVlookup product code 123 to pull in "UNITS" value ONLY if country is Australia

DATA SET 2:
COUNTRYPRODUCT CODEUNITS
MEXICO1235
AUSTRALIA12310
MEXICO45612
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
you can combine in a vlookup or index match uses &

=index( column to return , match ( cell with country & cell with code , range with country&range with code , 0 ))

see here
Book2
ABC
1CODEMEXICOAUSTRALIA
2123510
3
4DATA SET 2:
5COUNTRYPRODUCT CODEUNITS
6MEXICO1235
7AUSTRALIA12310
8MEXICO45612
Sheet1
Cell Formulas
RangeFormula
B2:C2B2=INDEX($C$6:$C$8,MATCH($A2&B1,$B$6:$B$8&$A$6:$A$8,0))
 
Upvote 0

Forum statistics

Threads
1,223,231
Messages
6,170,884
Members
452,364
Latest member
springate

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