excel compare current time value from sheet1 to time value range from sheet2 -
i trying compare time value sheet 1 sheet 2 , close match values in sheet1 -- b, c, d columns. whenever refresh cell should automatically update results in b, c, c, d see expected result
sheet 1 show current time i.e., cell a1 "=now()"
sheet1 ---------------------------------------------------- | | b | c | d | |--------------------------------------------------- | 12:55:00 | | | | ----------------------------------------------------
in sheet 2, data available in 4 columns below
-------------------------------------------------------- | no | start | end | date | |------------------------------------------------------- | 1 | 07:36:00 | 08:23:10 | 15/05/2015 | | 2 | 08:23:10 | 09:10:20 | 15/05/2015 | | 3 | 09:10:20 | 09:57:30 | 15/05/2015 | | 4 | 09:57:30 | 10:44:40 | 15/05/2015 | | 5 | 10:44:40 | 11:31:50 | 15/05/2015 | | 6 | 11:31:50 | 12:19:00 | 15/05/2015 | | 7 | 12:19:00 | 13:06:10 | 15/05/2015 | | 8 | 13:06:10 | 13:53:20 | 15/05/2015 | | 9 | 13:53:20 | 14:40:30 | 15/05/2015 | | 10 | 14:40:30 | 15:27:40 | 15/05/2015 | | 11 | 15:27:40 | 16:14:50 | 15/05/2015 | | 12 | 16:14:50 | 17:02:00 | 15/05/2015 | | 13 | 17:02:00 | 18:14:50 | 15/05/2015 | | 14 | 18:14:50 | 19:27:40 | 15/05/2015 | | 15 | 19:27:40 | 20:40:30 | 15/05/2015 | | 16 | 20:40:30 | 21:53:20 | 15/05/2015 | | 17 | 21:53:20 | 23:06:10 | 15/05/2015 | | 18 | 23:06:10 | 00:19:00 | 16/05/2015 | | 19 | 00:19:00 | 01:31:50 | 16/05/2015 | | 20 | 01:31:50 | 02:44:40 | 16/05/2015 | | 21 | 02:44:40 | 03:57:30 | 16/05/2015 | | 22 | 03:57:30 | 05:10:20 | 16/05/2015 | | 23 | 05:10:20 | 06:23:10 | 16/05/2015 | | 24 | 06:23:10 | 07:36:00 | 16/05/2015 | ---------------------------------------------------------
expected
sheet1 - if current time 12:55:00 on 15/05/2015
----------------------------------------------------------------------------- | | b | c | d | e | |-----------------------------------------------------------|---------------| | 12:55:00 | 7 | 12:19:00 | 13:06:10 | 15/05/2015 | -----------------------------------------------------------------------------
sheet1 - if current time 03:55:00 on 16/05/2015
----------------------------------------------------------------------------- | | b | c | d | e | |-----------------------------------------------------------|---------------| | 12:55:00 | 21 | 02:44:40 | 03:57:30 | 16/05/2015 | -----------------------------------------------------------------------------
for numbers using below formula not sure how achieve in case of time
=index(a1:a20,match(min(abs(a1:a20-d1)),abs(a1:a20-d1),0))
thanks
if assume dates entered different days want treat them though on same day, need subtract off days part before doing comparison.
since excel stores dates days decimal representing hours/seconds, can subtract off integer part of value.
here formula. array formula, entered ctrl+shift+enter.
=index(a1:a20,match(min(abs(a1:a20-int(a1:a20)-d1+int(d1))),abs(a1:a20-int(a1:a20)-d1+int(d1)),0))
for a1:a20
subtract off int(a1:a20)
. same thing d1
except d1
being subtracted, int
part gets added in.
Comments
Post a Comment