Vlookup a value but returning the closest date match (before the date)

bakarken

Board Regular
Joined
Sep 23, 2016
Messages
50
Office Version
  1. 2019
Platform
  1. Windows
Hi guys

Absolutely amazed at past help from here, and wonder if one of you can help me with a problem I'm having.

In Sheet1, I have:
Column A: Dates
Column B: Amounts

In cell C1, I'd like to type a specific date, and in Cell D1, I'd like to type a specific amount.
In cell E1, I'd like a formula that will return the closest date AT OR BEFORE the date in C1 (from the dates in column A), but the amount (in column B) must match exactly to D1.

Ideally, the first result would be anything same day, but if that does not exist, the date will be before D1 date.

I've attached an example.

Possible it would say 'No result' or something if it cannot find the amount at all in the list

Any help would be really appreciated!
 

Attachments

  • Example.png
    Example.png
    29.5 KB · Views: 8

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
If you use Excel 365, then something like the below can work
Sample.xlsx
ABCDE
101/01/20235006/01/20235005-Jan-23
202/01/2023100
305/01/202350
410/01/202311
515/01/202350
631/01/202350
Sheet2
Cell Formulas
RangeFormula
E1E1=LET(a,FILTER(A1:A6,B1:B6=D1,""), XLOOKUP(C1,a,a,"Not found",-1))
 
Upvote 0
I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
 
Upvote 0
Excel 2019
Thanks - but please put that in your account details as requested so that it is always available to helpers and we don't have to ask you again next time. :)

Try a formula like this.

23 10 19.xlsm
ABCDE
11/01/2023506/01/2023505/01/2023
22/01/2023100
35/01/202350
410/01/202311
515/01/202350
631/01/202350
Find Date
Cell Formulas
RangeFormula
E1E1=IFERROR(AGGREGATE(14,6,A1:A6/((B1:B6=D1)*(A1:A6<=C1)),1),"Not found")
 
Upvote 0
Solution
Thanks - but please put that in your account details as requested so that it is always available to helpers and we don't have to ask you again next time. :)

Try a formula like this.

23 10 19.xlsm
ABCDE
11/01/2023506/01/2023505/01/2023
22/01/2023100
35/01/202350
410/01/202311
515/01/202350
631/01/202350
Find Date
Cell Formulas
RangeFormula
E1E1=IFERROR(AGGREGATE(14,6,A1:A6/((B1:B6=D1)*(A1:A6<=C1)),1),"Not found")

Thank you so much! This seems to work :) You have helped me a lot, really appreciated!! :)
Account preferences updated also, thank you
 
Upvote 0
Thank you so much! This seems to work :) You have helped me a lot, really appreciated!! :)
Account preferences updated also, thank you
You're welcome. Thanks for the follow-up. :)

.. and thanks for updating your version details. (y)
 
Upvote 0

Forum statistics

Threads
1,215,069
Messages
6,122,956
Members
449,096
Latest member
Anshu121

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