View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Find next time in a range


Sub SortTime()
Dim rng As Range
Dim cnt As Long, i As Long
Dim j As Long
Dim temp As Date
Set rng = Range("A1:H5")
cnt = rng.Count
For i = 1 To cnt - 1
For j = i + 1 To cnt
If rng(i) rng(j) Then
temp = rng(i)
rng(i) = rng(j)
rng(j) = temp
End If
Next
Next

End Sub


--
Regards,
Tom Ogilvy


"Martin Wheeler" wrote in message
...
XL2003, Win xp

Is there a way to find the next time in a range, where the times are
arranged randomly? So in range A1:H5 the code looks for the time after

the
nominated time.

So:-
If A = 10:30AM and the next time in the range is 11:15AM then
B=11:15AM
End if
And then I would make A=11:15AM and look for the next time in the range.
And so on until I have my list

Any help would be greatly appreciated.
Ta,
Martin