Can Vlookup return the second occurance?

giftkae8

New Member
Joined
Apr 26, 2011
Messages
2
Hi,

I am working on the project and I am stuck with the vlookup that always pick up the first value of the array.

Here is example of my work:

Sheet 1
Product Customer Selling Date Market Price Concatenate
orange ABC 1/10/2011 5 orange ABC
apple ABC 1/15/2011 8 apple ABC
orange ABC 1/14/2011 5 orange ABC
apple XYZ 1/18/2011 7 apple XYZ

Sheet 2
Concate Promotion# Product Customer Start date End Date Discount$
orange ABC 1001 orange ABC 1/14/2011 1/18/2011 $2
orange ABC 1002 orange ABC 1/9/2011 1/12/2011 $1
apple ABC 1003 apple ABC 1/13/2011 1/16/2011 $2
apple XYZ 1004 apple XYZ 1/17/2011 1/25/2011 $2

Remark : I must sort by Discount$ (decending) to give the best discount amount to the customer.

What I want is, on Sheet 1, I need to see which promotion works best for each selling transaction. Customer will get the discount if they sell the product within the promotion date range.

If I only use the basic VLOOKUP, here is what I get:

Product Customer Selling Date Market Price Concatenate Promotion#
orange ABC 1/10/2011 5 orange ABC 1001
apple ABC 1/15/2011 8 apple ABC 1003
orange ABC 1/14/2011 5 orange ABC 1001
apple XYZ 1/18/2011 7 apple XYZ 1004

You will see that the first row turns the value to "Promotion 1001" which the selling date is not within Promotion 1001's date range.
How can I get the correct result which it has to be the second occurance (Promotion 1002)? without using Access or VBA.

Please help.
Thank you so much.
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Try...

Sheet1, F2...
Code:
=INDEX(Sheet2!$B$2:$B$5,MATCH(1,IF(Sheet2!$A$2:$A$5=E2,
    IF(C2>=Sheet2!$E$2:$E$5,IF(C2<=Sheet2!$F$2:$F$5,1))),0))

which must be confirmed with control+shift+enter, not just enter, and copied down.
 
Upvote 0

Forum statistics

Threads
1,224,597
Messages
6,179,808
Members
452,944
Latest member
2558216095

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