I am trying to create a formula that looks for a date in table and if it finds the date, it will reference the 4th column of the table (foreign exchange rate), if the date does not exist it will then look for the prior date in the table. My table is exchange rates for a period and there are bank holidays and weekends with no exchange rate, so there are date gaps in the table.
I started off with the formula: =VLOOKUP(F30,Sheet3!$A$1:$D$856,4,FALSE)
, where F30 is the date; however, it will produce an #N/A if F30 is not an exact date in the table A1:D856.
I then created a formula:
=IF(ISNA(VLOOKUP(F30,Sheet3!$A$1:$D$856,4,FALSE)),
VLOOKUP(F30-1,Sheet3!$A$1:$D$856,4,FALSE),VLOOKUP(F30,Sheet3!$A$1:$D$856,4,FALSE))
This will work if the date (F30) or the prior date (F30-1) exists in the table. However, if neither exists, I want the formula to try F30-2, F30-3 and F30-4. My table covers about 3.5 years of exchange rate data and the biggest gap in days is 4 days in a row without an exchange rate.
My current solution is just to change the Date-1 to Date-2, or Date-3, so on, until it finds a result.
Thanks
Aucun commentaire:
Enregistrer un commentaire