Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Sorting DateTime Values in Array
I have an array of dates/times in the format "mm/dd/yy hh:mm". The
array is one-dimensional. I want to pick the max/min, but it won't work. My code: msgbox WorksheetFunction.Max(arrResults()) I am getting "0" when I run this code now. I read he http://tinyurl.com/q6jm6 this is a misbehavior on Excel's part and I'll have to find another way. The problem with the proposed solution is that it uses dateserial function. I also need the time and I don't think the dateserial function keeps the time (am I wrong?). So here's my new thinking: Couldn't I just sort the array and pick the first or last element as min or max? Anyone have a good bubble sort routine for date/time combinations OR a friendly pointer on how to write one (i.e., what functions to use that aren't broken/buggy). There seems to be few topics on this subject in the newsgroups and I desperately need to get something working. Thank you for taking the time to read my post. -Kevin |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Sorting DateTime Values in Array
Probably be quicker to do
Dim maxDate As Date Dim dt as Date For i = 1 To 10 dt = arr(i) If maxDate < dt Then maxDate = dt Next msgbox "Max date is " & format(maxDate, "mm/dd/yyyy hh:mm") -- Regards, Tom Ogilvy "Kevin" wrote: I have an array of dates/times in the format "mm/dd/yy hh:mm". The array is one-dimensional. I want to pick the max/min, but it won't work. My code: msgbox WorksheetFunction.Max(arrResults()) I am getting "0" when I run this code now. I read he http://tinyurl.com/q6jm6 this is a misbehavior on Excel's part and I'll have to find another way. The problem with the proposed solution is that it uses dateserial function. I also need the time and I don't think the dateserial function keeps the time (am I wrong?). So here's my new thinking: Couldn't I just sort the array and pick the first or last element as min or max? Anyone have a good bubble sort routine for date/time combinations OR a friendly pointer on how to write one (i.e., what functions to use that aren't broken/buggy). There seems to be few topics on this subject in the newsgroups and I desperately need to get something working. Thank you for taking the time to read my post. -Kevin |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Sorting Values Without Sorting Formulas | Excel Discussion (Misc queries) | |||
Array: Counting multiple values within array | Excel Worksheet Functions | |||
fastest sorting routine for 2-D array of long values | Excel Programming | |||
Sorting unique values and returning values from a formula | Excel Programming | |||
Convert values in a variant array to integer values | Excel Programming |