Is Vlookup and INDEX MATCH the best solution

Tim_D

New Member
Joined
Apr 23, 2020
Messages
12
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi all. I have a data table where I need to pull the product cost based on the closest "cost date" to the actual "Order Date".
The cost data spreadsheet is set up like the image below and I cannot find a formula that works with the data set up like this.

1715883373084.png


I am only able to get this work if I convert all the data into columns. The formula works as expected with the data in this column format, but it will be too labor intensive to have to update the converted data every time the cost data is updated by someone else. I cannot figure out how to make this formula work for the data setup in the top image.

{=VLOOKUP(F2,INDEX(B:C,MATCH(E2,A:A,0),0):INDEX(B:C,MATCH(E2,A:A,0)+COUNTIF(A:A,E2)-1,0),2,TRUE)}

1715883552587.png


Any help would be greatly appreciated.

Timothy
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
How about
Excel Formula:
=INDEX(B29:H30,XMATCH(E2,A29:A30),XMATCH(E2,B28:H28,-1))
 
Upvote 0
Solution
How about
Excel Formula:
=INDEX(B29:H30,XMATCH(E2,A29:A30),XMATCH(E2,B28:H28,-1))
Awesome, worked like a charm!!!! Thank you so much for the quick reply.

I only had to change the on small thing from (E2,B28:H28,-1) to (F2,B28:H28,-1) to reference the date cell, but other than that it worked perfectly.
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,224,815
Messages
6,181,135
Members
453,021
Latest member
Justyna P

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