I have a formula that is finding the closest time match to a user entered time. The formula works great when the Time column does not have any blank cells, but the second it sees a blank cell, I get the #VALUE! error. How do I get this formula to exclude blank cells and only index/match existing data?
{=INDEX(B2:B5000,MATCH(MIN(ABS('User Input'!G8-B2:B5000)),ABS('User Input'!G8-B2:B5000),-1))}
Your lookup range cannot guarantee a sort, since you use the ABS() value of a data operation. The new XLookup() function which was just released to the Office 365 monthly channel can do a simpler formula that does not require any sorting.
=XLOOKUP(MIN(ABS(Sheet2!A1-B2:B10)),ABS(Sheet2!A1-B2:B10),B2:B10,,1)
If you can't use XLookup, you could use a helper column (eg in column C, with the formula =ABS('User Input'!$G$8-B2)
, copy down and sort the data by that column. Then you can simplify the Index/Match to
=INDEX(C2:C5000,MATCH(MIN(C2:C5000),C2:C5000,-1))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.