Values corresponding to the closest date match

Suza2007

New Member
Joined
Jun 21, 2018
Messages
4
Hi All,

I have the following raw data:

A
B
C
F
G
Material
Bill Date
Unit Price
14/05/2018
A
03/05/2018
323
A
10/05/2018
300
Material
Unit Price
A
28/05/2018
300
A
323
A
02/06/2018
278
C
1050
A
16/06/2018
210
R
500
C
21/12/2017
1050
C
22/12/2017
1050
C
27/12/2017
1050
C
29/01/2018
900
C
29/01/2018
900
R
29/03/2018
500
R
16/04/2018
490
R
19/04/2018
490
R
22/05/2018
470
R
25/05/2018
470
R
15/06/2018
450
R
20/06/2018
450
R
21/06/2018
450

<tbody>
</tbody>

Am trying to create a report as on 14th May 2018 where I need unit price corresponding to the nearest date.
Hence for “A” I must get unit price as 300 & “C” as 900 as that is last latest date (29/01/2018) & “R” as 490.

Am using “=IFERROR(VLOOKUP(F5,B2:D20,3,0), INDEX(C3:C20,MATCH(G2,D3:D20,-1)+1))”, however it gives me the very first value(unit price) for each material.

Any help is much appreciated.

Thanks
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
This?


Excel 2010
ABCDEFG
1MaterialBill DateUnit Price5/14/2018
2A5/3/2018323
3A5/10/2018300MaterialUnit Price
4A5/28/2018300A300
5A6/2/2018278C900
6A6/16/2018210R490
7C12/21/20171050
8C12/22/20171050
9C12/27/20171050
10C1/29/2018900
11C1/29/2018900
12R3/29/2018500
13R4/16/2018490
14R4/19/2018490
15R5/22/2018470
16R5/25/2018470
17R6/15/2018450
18R6/20/2018450
19R6/21/2018450
Sheet13
Cell Formulas
RangeFormula
F4{=VLOOKUP($F$1,IF($A$2:$A$19=E4,$B$2:$C$19),2,1)}
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Last edited:
Upvote 0
Amazing. Thank you so much for the help.

just one quick question, after entering the formula in cell "F4" when i double clicked it was giving me #N/A error.
 
Upvote 0
This formula isnt working for me on F5 & F6 cells though i tried entering it manually instead of copy paste. please help
 
Upvote 0
What I said about holding down ctrl-shift with the enter doesn't apply when you drag the formula or copy and paste, only if you actually enter it (either for the first time or after double clicking/pressing F2 etc)
 
Upvote 0

Forum statistics

Threads
1,214,646
Messages
6,120,720
Members
448,986
Latest member
andreguerra

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