vlookup two values and return another one

deep_101

New Member
Joined
Oct 16, 2009
Messages
6
Hi All,

First time posting here and im not that familiar with VBA.

I have two workbooks which are data dumps from another program. Say I have WO #, Task #, and Cost in workbook1 and WO #, Task # in workbook2. I need to compare the WO# in workbook2 with WO# in workbook1 if it matches I need to compare the Task # in workbook2 with the Task# in workbook1 (but it must compare the same row in which the WO # match was found) then it must return the cost from workbook1 to workbook2 ( again the cost must come from the same row in which the WO and Task match were found in).

This could be a VBA code or even a formula that does not matter.

Your help would be appreciated.

Thank you.
 
Late to the party I know, but since SUMPRODUCT() formulas are problematic in large quantities, I thought I'd point out the INDEX/MATCH alternative for this scenario. INDEX/MATCH is the most robust tool for lookups and worth using every chance you get.

Most people abandon them when there is a two- or three-criteria to the match, but you don't have to. Something like this works fine:

=INDEX([wb2]sheet1!C$1:C$1000, MATCH( A2 & B2, INDEX([wb2]sheet1!A$1:A$1000 & [wb2]sheet1!B$1:B$1000,0),0))

If there is a chance of some odd duplication (if the values are numeric and small, this is very possible), then add a separator, like so:

=INDEX([wb2]sheet1!C$1:C$1000, MATCH( A2 & "-" & B2, INDEX([wb2]sheet1!A$1:A$1000 & "-" & [wb2]sheet1!B$1:B$1000,0),0))
 
Upvote 0

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.

Forum statistics

Threads
1,215,446
Messages
6,124,900
Members
449,194
Latest member
JayEggleton

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