Index match/VBA/Vlookup

Tocix

New Member
Joined
Apr 17, 2016
Messages
48
Office Version
  1. 365
Hello,

I have a workbook with two worksheet. Please help me out with anything Vlookup/Index match, VBA etc..

On sheet1 I have column A= part number, column G=price and column M=location. On sheet2 I have column A= part number, column D= date, column M=price and column K=location.

On sheet2 on Column A has same item number with multiple rows with different date on column D. is there a way that can be done in VBA/Vlookup anything that look up the oldest date and copy price on column G and location to sheet1?


Thank you very much. This would save me half day of work
sheet1
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]G[/TD]
[TD]M[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Part number[/TD]
[TD]Price[/TD]
[TD]Location[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]G1APPLE[/TD]
[TD]8.00[/TD]
[TD]B13[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]G2PEAR[/TD]
[TD]9.00[/TD]
[TD]b5[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]G3ORANGE[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]



[TABLE="class: grid, width: 300"]
<tbody>[TR]
[TD][/TD]
[TD]a[/TD]
[TD]d[/TD]
[TD]k[/TD]
[TD]m[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD]part number[/TD]
[TD]date[/TD]
[TD]location[/TD]
[TD]price[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]G1APPLE[/TD]
[TD]10/08/2019[/TD]
[TD]B12[/TD]
[TD]5.00[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]G1APPLE[/TD]
[TD]10/01/2019[/TD]
[TD]B13[/TD]
[TD]8.00[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]G2PEAR[/TD]
[TD]10/03/2019[/TD]
[TD]B5[/TD]
[TD]9.00[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]G2PEAR[/TD]
[TD]12/05/2019[/TD]
[TD]B6[/TD]
[TD]6.50[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Try this array formula

<table border="1" cellspacing="0" style="font-family:Calibri,Arial; font-size:11pt; background-color:#ffffff; "> <colgroup><col style="font-weight:bold; width:30px; " /><col style="width:158.73px;" /><col style="width:76.04px;" /><col style="width:76.04px;" /></colgroup><tr style="background-color:#cacaca; text-align:center; font-weight:bold; font-size:8pt; "><td > </td><td >A</td><td >B</td><td >C</td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >1</td><td >Part number</td><td >Price</td><td >Location</td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >2</td><td >G1APPLE</td><td style="text-align:right; ">8</td><td >B13</td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >3</td><td >G2PEAR</td><td style="text-align:right; ">9</td><td >B5</td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >4</td><td >G3ORANGE</td><td > </td><td > </td></tr></table><br /><table style="font-family:Arial; font-size:10pt; border-style: groove ;border-color:#00ff00;background-color:#fffcf9; color:#000000; "><tr><td ><b></b></td></tr><tr><td ><table border = "1" cellspacing="0" cellpadding="2" style="font-family:Arial; font-size:9pt;"><tr style="background-color:#cacaca; font-size:10pt;"><td >Cell</td><td >Array Formula</td></tr><tr><td >B2</td><td >{=IFERROR(INDEX(Sheet2!$D$2:$D$5,MAX((Sheet2!$A$2:$A$5=$A2)*(Sheet2!$B$2:$B$5=MIN(IF(Sheet2!$A$2:$A$5=$A2,Sheet2!$B$2:$B$5)))*ROW(Sheet2!$D$2:$D$5)-ROW(Sheet2!$D$1))),"")}</td></tr><tr><td >C2</td><td >{=IFERROR(INDEX(Sheet2!$C$2:$C$5,MAX((Sheet2!$A$2:$A$5=$A2)*(Sheet2!$B$2:$B$5=MIN(IF(Sheet2!$A$2:$A$5=$A2,Sheet2!$B$2:$B$5)))*ROW(Sheet2!$D$2:$D$5)-ROW(Sheet2!$D$1))),"")}</td></tr></table></td></tr></table>

Array formulas
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself.

After entering the 2 formulas copy down.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,212
Members
452,618
Latest member
Tam84

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