Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sorting Values Without Sorting Formulas SBX Excel Discussion (Misc queries) 2 April 12th 09 11:17 PM
Array: Counting multiple values within array Trilux_nogo Excel Worksheet Functions 4 April 16th 07 03:12 AM
fastest sorting routine for 2-D array of long values RB Smissaert Excel Programming 8 May 6th 06 05:06 PM
Sorting unique values and returning values from a formula MarcusA Excel Programming 2 March 1st 06 05:36 AM
Convert values in a variant array to integer values Graham McNeill Excel Programming 1 November 13th 04 12:47 AM


All times are GMT +1. The time now is 06:49 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"