Finding The Closest To A Particular Time

TGM

Board Regular
Joined
Jul 31, 2005
Messages
107
Hello,

I hope someone can help as I haven't a clue about where to start with this one.

I have the following three columns in a worksheet.

I would like to search columns A and B for the cell that is closest in time to 12:00:00.

Once it has found it I would like to have the corresponding ODDS for that time displayed in cell D1.

In this case it would be 3.45 as cell A24 is closest to 12:00:00.
HistoricBetfairDataAnalysis.xls
ABCD
1LATEST_TAKENFIRST_TAKENODDS
203/02/200614:18:1103/02/200614:16:532.72
303/02/200614:18:1603/02/200614:15:292.74
403/02/200614:18:2603/02/200614:15:392.76
503/02/200614:18:2803/02/200614:14:592.78
603/02/200614:18:2903/02/200614:11:502.80
703/02/200614:18:3603/02/200614:11:492.82
803/02/200614:18:4003/02/200614:11:012.84
903/02/200614:18:4103/02/200614:10:592.86
1003/02/200614:18:4303/02/200614:10:542.88
1103/02/200614:18:4703/02/200614:10:212.90
1203/02/200614:18:5002/02/200621:28:182.92
1303/02/200614:18:5203/02/200614:10:012.94
1403/02/200614:20:2903/02/200614:09:402.96
1503/02/200614:20:4302/02/200621:31:282.98
1603/02/200614:20:4302/02/200621:08:493.05
1703/02/200614:20:0902/02/200621:31:023.10
1803/02/200614:04:2803/02/200610:56:203.15
1903/02/200613:52:1002/02/200621:03:143.20
2003/02/200613:32:4602/02/200621:48:513.25
2103/02/200613:08:0802/02/200620:35:013.30
2203/02/200612:22:5002/02/200622:26:093.35
2303/02/200612:15:5702/02/200621:48:513.40
2403/02/200612:14:2102/02/200621:48:513.45
2503/02/200610:09:5802/02/200622:07:103.50
2603/02/200610:08:3702/02/200622:22:373.55
2703/02/200610:11:4102/02/200622:41:593.60
2803/02/200610:09:0902/02/200622:41:593.65
2903/02/200609:19:1402/02/200622:41:593.70
3002/02/200622:42:1602/02/200622:42:073.75
Sheet1


Many thanks for any help,

Scott
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Since your data spans over more than one day, do you want the search to be specific to a particular day or are you looking for an overall closest time? If the latter, what happens if the closest time occurs on more than one day? Do you want the first or last occurance? Or do you want each occurance?
 
Upvote 0
Cheers for the reply,

I am looking for the latter.

The times on the the previous day will never be near enough to be of concern.

Many thanks,

Scott
 
Upvote 0
Try the following formula which needs to be confirmed with CONTROL+SHIFT+ENTER, not just ENTER...

=IF(N(E2),INDEX(C2:C30,MIN(IF(ABS((A2:B30-INT(A2:B30))-E2)=MIN(ABS((A2:B30-INT(A2:B30))-E2)),ROW(A2:B30)-ROW(A2)+1))),"")

...where E2 contains the target time, such as 12:00:00.

Hope this helps!
 
Upvote 0
Thanks once more Greg.

It seems to work for me. I haven't a clue as to how you've done it though.

I will look at it tonight to see if I can unravel it.

Thanks again,
Scott
 
Upvote 0
Did I misunderstand? I thought you wanted to search both Columns A and B for the closest match. Or are you searching one column at a time?
 
Upvote 0
No you didn't misunderstand, I do want to search both columns for the closest match.
 
Upvote 0
Does Greg's formula in fact return the desired result? If so, can you post it. I may have over-thought my formula... :)
 
Upvote 0

Forum statistics

Threads
1,215,353
Messages
6,124,463
Members
449,163
Latest member
kshealy

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