JohnZ1156
Board Regular
- Joined
- Apr 10, 2021
- Messages
- 109
- Office Version
- 2021
- Platform
- Windows
I have a data table with dates in column A and values in column B.
In cell C1 I enter the date for the Vlookup.
I would like to use Vlookup to search for a date in column A and return the corresponding value in column B.
Now,
Some dates may not have a corresponding value in column B. (an empty cell)
If the date found by Vlookup has no corresponding value in column B, I'd like it to return the Previous days value.
If THAT date has no corresponding value, I'd like it to return the NEXT Previous days value, and so on.
I tried a nested IF function with Vlookup something like this:
I was trying to get it to go to the prior date when no value was found.
=IF(VLOOKUP(C1,Table1,2)=0,VLOOKUP(C1-1,Table1,2),IF(VLOOKUP(C1-1,Table1,2)=0,VLOOKUP(C1-2,Table1,2),IF(VLOOKUP(C1-2,Table1,2)=0,VLOOKUP(C1-3,Table1,2),IF(VLOOKUP(C1-3,Table1,2)=0,VLOOKUP(C1-4,Table1,2),IF(VLOOKUP(C1-4,Table1,2)=0,VLOOKUP(C1-5,Table1,2),IF(VLOOKUP(C1-5,Table1,2)=0,VLOOKUP(C1-6,Table1,2),IF(VLOOKUP(C1-6,Table1,2)=0,VLOOKUP(C1-7,Table1,2),VLOOKUP(C1,Table1,2))))))))
Thanks for your help in advance.
In cell C1 I enter the date for the Vlookup.
I would like to use Vlookup to search for a date in column A and return the corresponding value in column B.
Now,
Some dates may not have a corresponding value in column B. (an empty cell)
If the date found by Vlookup has no corresponding value in column B, I'd like it to return the Previous days value.
If THAT date has no corresponding value, I'd like it to return the NEXT Previous days value, and so on.
I tried a nested IF function with Vlookup something like this:
I was trying to get it to go to the prior date when no value was found.
=IF(VLOOKUP(C1,Table1,2)=0,VLOOKUP(C1-1,Table1,2),IF(VLOOKUP(C1-1,Table1,2)=0,VLOOKUP(C1-2,Table1,2),IF(VLOOKUP(C1-2,Table1,2)=0,VLOOKUP(C1-3,Table1,2),IF(VLOOKUP(C1-3,Table1,2)=0,VLOOKUP(C1-4,Table1,2),IF(VLOOKUP(C1-4,Table1,2)=0,VLOOKUP(C1-5,Table1,2),IF(VLOOKUP(C1-5,Table1,2)=0,VLOOKUP(C1-6,Table1,2),IF(VLOOKUP(C1-6,Table1,2)=0,VLOOKUP(C1-7,Table1,2),VLOOKUP(C1,Table1,2))))))))
Thanks for your help in advance.