Pick the first value from a range of data which is more than X value

gnaga

Well-known Member
Joined
Jul 9, 2002
Messages
748
Office Version
  1. 365
  2. 2016
  3. 2013
Platform
  1. Windows
Book1
EFGHI
6
710:00:00 AM
8
9
10
11
1210:00:00 AM
1310:06:00 AM
1410:06:00 AM
1510:12:00 AM
1610:12:00 AM
1710:18:00 AM
1810:18:00 AM
1910:24:00 AM
2010:24:00 AM
2110:27:00 AM 
2210:27:00 AM
2310:30:00 AM
2410:30:00 AM
2510:42:00 AM
2610:42:00 AM
2710:54:00 AM
28
29
30
31
3210:54:00 AM
3311:00:00 AM
3411:00:00 AM
3511:06:00 AM
36
Sheet1
Cell Formulas
RangeFormula
H21H21=INDEX(F8:F35,MATCH(TRUE,INDEX(F8:F35>(F7+(60/1440)),0),0))


Formula in the cell H21 returns blank cell. I wish to pick the time which is just crossing more than an hour than "F7". The correct result is "F35" should return. I am finding it difficult to get this correct. Please help.
 
Last edited:

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Try this:

=INDEX(F8:F35,MATCH(1,INDEX((F8:F35>F7+(60/1440))*(F8:F35<=1440),0),0))
 
Upvote 0
If your times are always in ascending order like your sample, then another way would be

Excel Formula:
=AGGREGATE(15,6,F8:F35/(F8:F35>F7+1/24),1)
 
Upvote 0
Thanks Peter_SSs,

Your solution is also working fine. In fact I would like to highlight the hour which is crossing one hour from the specific time (Row 5) as I given in my example. Could you please give some guidance how to build formula for conditional formatting.

Book1
EFGHIJKLMNOPQRSTUVWXYZAAABACADAEAF
5SunMonTueWedThuFriSat
64:0010:0016:0022:004:0010:0016:0022:004:0010:0016:0022:004:0010:0016:0022:004:0010:0016:0022:004:0010:0016:0022:004:0010:0016:0022:00
722:0022:0022:0022:0022:0022:0022:00
822:0922:1222:0322:0322:0322:0622:03
922:12
1022:15
1110:0022:0910:0022:1510:0022:0310:0022:0310:0022:0310:0016:0022:0610:0022:03
1210:0622:1210:1222:1810:0622:0610:0922:0610:0622:0610:0916:0622:0910:0622:06
1310:0622:1210:1222:1810:0622:0610:0922:0610:0622:0610:0922:0910:0616:0022:06
1410:1222:1510:1822:2110:1222:0910:1522:0910:1222:0910:1522:1210:1216:0622:09
1510:1222:1510:1822:2110:1222:0910:1522:0910:1222:0910:1522:1210:1222:09
1610:1822:2110:2422:2710:1822:1510:2122:1510:1822:1510:2122:1810:1822:15
1710:1822:2110:2422:2710:1822:1510:2122:1510:1822:1510:2122:1810:1822:15
1810:2422:2710:3022:3310:2422:2110:2722:2110:2422:2110:2722:2410:2422:21
1910:2410:3010:2410:2710:2410:2710:24
2010:2710:4210:2710:3010:2710:3010:27
2110:2710:4222:3322:2110:27
2210:3010:4822:3622:2410:30
2310:3010:4810:2710:3010:3010:3010:27
2410:4211:0010:3610:4210:3910:3910:39
254:0010:4216:004:0011:0016:004:0010:3616:004:0010:4216:004:0010:3916:004:0010:3916:064:0010:3916:06
264:0610:5416:274:0611:0916:184:0610:4516:184:0610:5116:184:0610:4816:184:0610:4816:244:0610:4816:24
2716:2711:0916:1816:1816:1816:1816:2416:24
2817:0611:1516:5416:5116:5116:5716:5417:00
294:0617:0622:274:0616:544:0616:514:0616:514:0616:5722:214:0616:544:0617:00
304:1217:3622:304:1217:244:1217:214:1217:214:1217:2722:244:1217:244:1217:30
3110:5417:364:1211:1517:2410:4517:2110:5117:2110:4817:2710:4817:2410:4817:30
3211:0017:484:1511:2117:3610:5117:3310:5717:3310:5417:4810:5417:3610:5417:42
334:1211:004:1511:214:1210:514:1210:574:1210:544:1210:544:1210:54
344:3611:064:3011:274:3310:574:2711:034:3311:004:2711:004:2711:00
Sheet1
 
Upvote 0
When I use the given formula for the conditional formatting I get the below result. What could not get what I am doing is not correct.

Book1
DEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAG
4
5SunMonTueWedThuFriSat
64:0010:0016:0022:004:0010:0016:0022:004:0010:0016:0022:004:0010:0016:0022:004:0010:0016:0022:004:0010:0016:0022:004:0010:0016:0022:00
722:0022:0022:0022:0022:0022:0022:00
822:0922:1222:0322:0322:0322:0622:03
922:12
1022:15
1110:0022:0910:0022:1510:0022:0310:0022:0310:0022:0310:0016:0022:0610:0022:03
1210:0622:1210:1222:1810:0622:0610:0922:0610:0622:0610:0916:0622:0910:0622:06
1310:0622:1210:1222:1810:0622:0610:0922:0610:0622:0610:0922:0910:0616:0022:06
1410:1222:1510:1822:2110:1222:0910:1522:0910:1222:0910:1522:1210:1216:0622:09
1510:1222:1510:1822:2110:1222:0910:1522:0910:1222:0910:1522:1210:1222:09
1610:1822:2110:2422:2710:1822:1510:2122:1510:1822:1510:2122:1810:1822:15
1710:1822:2110:2422:2710:1822:1510:2122:1510:1822:1510:2122:1810:1822:15
1810:2422:2710:3022:3310:2422:2110:2722:2110:2422:2110:2722:2410:2422:21
1910:2410:3010:2410:2710:2410:2710:24
2010:2710:4210:2710:3010:2710:3010:27
2110:2710:4222:3322:2110:27
2210:3010:4822:3622:2410:30
2310:3010:4810:2710:3010:3010:3010:27
2410:4211:0010:3610:4210:3910:3910:39
254:0010:4216:004:0011:0016:004:0010:3616:004:0010:4216:004:0010:3916:004:0010:3916:064:0010:3916:06
264:0610:5416:274:0611:0916:184:0610:4516:184:0610:5116:184:0610:4816:184:0610:4816:244:0610:4816:24
2716:2711:0916:1816:1816:1816:1816:2416:24
2817:0611:1516:5416:5116:5116:5716:5417:00
294:0617:0622:274:0616:544:0616:514:0616:514:0616:5722:214:0616:544:0617:00
304:1217:3622:304:1217:244:1217:214:1217:214:1217:2722:244:1217:244:1217:30
3110:5417:364:1211:1517:2410:4517:2110:5117:2110:4817:2710:4817:2410:4817:30
3211:0017:484:1511:2117:3610:5117:3310:5717:3310:5417:4810:5417:3610:5417:42
334:1211:004:1511:214:1210:514:1210:574:1210:544:1210:544:1210:54
344:3611:064:3011:274:3310:574:2711:034:3311:004:2711:004:2711:00
35
Sheet1
Cells with Conditional Formatting
CellConditionCell FormatStop If True
E7:AF34Expression=AGGREGATE(15,6,E7:E34/(E7:E34>E6+1/24),1)textNO
 
Upvote 0
I would like to highlight the hour which is crossing one hour from the specific time (Row 5) as I given in my example.
It actually looks like you meant row 6 in your example?

To get the results shown in post #5 you need to assess each cell value against the result of the AGGREGATE formula and you also need to check that the cell is the first cell that matches the AGGREGATE formula.

So, try this, applied to the range E7:AF34

gnaga.xlsm
EFGHIJKLMNOPQRSTUVWXYZAAABACADAEAF
5SunMonTueWedThuFriSat
64:0010:0016:0022:004:0010:0016:0022:004:0010:0016:0022:004:0010:0016:0022:004:0010:0016:0022:004:0010:0016:0022:004:0010:0016:0022:00
722:0022:0022:0022:0022:0022:0022:00
822:0922:1222:0322:0322:0322:0622:03
922:12
1022:15
1110:0022:0910:0022:1510:0022:0310:0022:0310:0022:0310:0016:0022:0610:0022:03
1210:0622:1210:1222:1810:0622:0610:0922:0610:0622:0610:0916:0622:0910:0622:06
1310:0622:1210:1222:1810:0622:0610:0922:0610:0622:0610:0922:0910:0616:0022:06
1410:1222:1510:1822:2110:1222:0910:1522:0910:1222:0910:1522:1210:1216:0622:09
1510:1222:1510:1822:2110:1222:0910:1522:0910:1222:0910:1522:1210:1222:09
1610:1822:2110:2422:2710:1822:1510:2122:1510:1822:1510:2122:1810:1822:15
1710:1822:2110:2422:2710:1822:1510:2122:1510:1822:1510:2122:1810:1822:15
1810:2422:2710:3022:3310:2422:2110:2722:2110:2422:2110:2722:2410:2422:21
1910:2410:3010:2410:2710:2410:2710:24
2010:2710:4210:2710:3010:2710:3010:27
2110:2710:4222:3322:2110:27
2210:3010:4822:3622:2410:30
2310:3010:4810:2710:3010:3010:3010:27
2410:4211:0010:3610:4210:3910:3910:39
254:0010:4216:004:0011:0016:004:0010:3616:004:0010:4216:004:0010:3916:004:0010:3916:064:0010:3916:06
264:0610:5416:274:0611:0916:184:0610:4516:184:0610:5116:184:0610:4816:184:0610:4816:244:0610:4816:24
2716:2711:0916:1816:1816:1816:1816:2416:24
2817:0611:1516:5416:5116:5116:5716:5417:00
294:0617:0622:274:0616:544:0616:514:0616:514:0616:5722:214:0616:544:0617:00
304:1217:3622:304:1217:244:1217:214:1217:214:1217:2722:244:1217:244:1217:30
3110:5417:364:1211:1517:2410:4517:2110:5117:2110:4817:2710:4817:2410:4817:30
3211:0017:484:1511:2117:3610:5117:3310:5717:3310:5417:4810:5417:3610:5417:42
334:1211:004:1511:214:1210:514:1210:574:1210:544:1210:544:1210:54
344:3611:064:3011:274:3310:574:2711:034:3311:004:2711:004:2711:00
Sheet2
Cells with Conditional Formatting
CellConditionCell FormatStop If True
E7:AF34Expression=AND(E7=AGGREGATE(15,6,E$8:E$34/(E$8:E$34>E$6+1/24),1),E7<>E6)textNO
 
Upvote 0
It actually looks like you meant row 6 in your example?

To get the results shown in post #5 you need to assess each cell value against the result of the AGGREGATE formula and you also need to check that the cell is the first cell that matches the AGGREGATE formula.

So, try this, applied to the range E7:AF34

gnaga.xlsm
EFGHIJKLMNOPQRSTUVWXYZAAABACADAEAF
5SunMonTueWedThuFriSat
64:0010:0016:0022:004:0010:0016:0022:004:0010:0016:0022:004:0010:0016:0022:004:0010:0016:0022:004:0010:0016:0022:004:0010:0016:0022:00
722:0022:0022:0022:0022:0022:0022:00
822:0922:1222:0322:0322:0322:0622:03
922:12
1022:15
1110:0022:0910:0022:1510:0022:0310:0022:0310:0022:0310:0016:0022:0610:0022:03
1210:0622:1210:1222:1810:0622:0610:0922:0610:0622:0610:0916:0622:0910:0622:06
1310:0622:1210:1222:1810:0622:0610:0922:0610:0622:0610:0922:0910:0616:0022:06
1410:1222:1510:1822:2110:1222:0910:1522:0910:1222:0910:1522:1210:1216:0622:09
1510:1222:1510:1822:2110:1222:0910:1522:0910:1222:0910:1522:1210:1222:09
1610:1822:2110:2422:2710:1822:1510:2122:1510:1822:1510:2122:1810:1822:15
1710:1822:2110:2422:2710:1822:1510:2122:1510:1822:1510:2122:1810:1822:15
1810:2422:2710:3022:3310:2422:2110:2722:2110:2422:2110:2722:2410:2422:21
1910:2410:3010:2410:2710:2410:2710:24
2010:2710:4210:2710:3010:2710:3010:27
2110:2710:4222:3322:2110:27
2210:3010:4822:3622:2410:30
2310:3010:4810:2710:3010:3010:3010:27
2410:4211:0010:3610:4210:3910:3910:39
254:0010:4216:004:0011:0016:004:0010:3616:004:0010:4216:004:0010:3916:004:0010:3916:064:0010:3916:06
264:0610:5416:274:0611:0916:184:0610:4516:184:0610:5116:184:0610:4816:184:0610:4816:244:0610:4816:24
2716:2711:0916:1816:1816:1816:1816:2416:24
2817:0611:1516:5416:5116:5116:5716:5417:00
294:0617:0622:274:0616:544:0616:514:0616:514:0616:5722:214:0616:544:0617:00
304:1217:3622:304:1217:244:1217:214:1217:214:1217:2722:244:1217:244:1217:30
3110:5417:364:1211:1517:2410:4517:2110:5117:2110:4817:2710:4817:2410:4817:30
3211:0017:484:1511:2117:3610:5117:3310:5717:3310:5417:4810:5417:3610:5417:42
334:1211:004:1511:214:1210:514:1210:574:1210:544:1210:544:1210:54
344:3611:064:3011:274:3310:574:2711:034:3311:004:2711:004:2711:00
Sheet2
Cells with Conditional Formatting
CellConditionCell FormatStop If True
E7:AF34Expression=AND(E7=AGGREGATE(15,6,E$8:E$34/(E$8:E$34>E$6+1/24),1),E7<>E6)textNO

Thanks Peter_SSs ??. I will apply and check your solution and let you know.
 
Upvote 0
Hi, Peter_SSs

Little starge behavior when I change the data value. Column "N" having two identical values both get formatted. Moreover if you could explain your formula would be grateful.

Book1
DEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAG
3
4
5SunMonTueWedThuFriSat
64:0010:0016:0022:004:0010:0016:0022:004:0010:0016:0022:004:0010:0016:0022:004:0010:0016:0022:004:0010:0016:0022:004:0010:0016:0022:00
722:0022:0022:0022:0022:0022:0022:00
822:1522:2022:0522:0522:0522:1022:05
922:20
1022:25
1110:0022:1510:0022:2510:0022:0510:0022:0510:0022:0510:0016:0022:1010:0022:05
1210:1022:2010:2022:3010:1022:1010:1522:1010:1022:1010:1516:1022:1510:1022:10
1310:1022:2010:2022:3010:1022:1010:1522:1010:1022:1010:1522:1510:1016:0022:10
1410:2022:2510:3022:3510:2022:1510:2522:1510:2022:1510:2522:2010:2016:1022:15
1510:2022:2510:3022:3510:2022:1510:2522:1510:2022:1510:2522:2010:2022:15
1610:3022:3510:4022:4510:3022:2510:3522:2510:3022:2510:3522:3010:3022:25
1710:3022:3510:4022:4510:3022:2510:3522:2510:3022:2510:3522:3010:3022:25
1810:4022:4510:5022:5510:4022:3510:4522:3510:4022:3510:4522:4010:4022:35
1910:4010:5010:4010:4510:4010:4510:40
2010:4511:1010:4510:5010:4510:5010:45
2110:4511:1022:5522:3510:45
2210:5011:2023:0022:4010:50
2310:5011:2010:4510:5010:5010:5010:45
2411:1011:4011:0011:1011:0511:0511:05
254:0011:1016:004:0011:4016:004:0011:0016:004:0011:1016:004:0011:0516:004:0011:0516:104:0011:0516:10
264:1011:3016:454:1011:5516:304:1011:1516:304:1011:2516:304:1011:2016:304:1011:2016:404:1011:2016:40
2716:4511:5516:3016:3016:3016:3016:4016:40
2817:5012:0517:3017:2517:2517:3517:3017:40
294:1017:5022:454:1017:304:1017:254:1017:254:1017:3522:354:1017:304:1017:40
304:2018:4022:504:2018:204:2018:154:2018:154:2018:2522:404:2018:204:2018:30
3111:3018:404:2012:0518:2011:1518:1511:2518:1511:2018:2511:2018:2011:2018:30
3211:4019:004:2512:1518:4011:2518:3511:3518:3511:3019:0011:3018:4011:3018:50
334:2011:404:2512:154:2011:254:2011:354:2011:304:2011:304:2011:30
345:0011:504:5012:254:5511:354:4511:454:5511:404:4511:404:4511:40
35
36
Sheet1
Cells with Conditional Formatting
CellConditionCell FormatStop If True
E7:AF34Expression=AND(E7=AGGREGATE(15,6,E$8:E$34/(E$8:E$34>E$6+1/24),1),E7<>E6)textNO
 
Upvote 0

Forum statistics

Threads
1,215,410
Messages
6,124,755
Members
449,187
Latest member
hermansoa

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