LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
Tom Tom is offline
external usenet poster
 
Posts: 8
Default sorting dates

Anybody have ideas on how to sort dates when they are in this format:
dd.mm.yyyy hh:mm:ss?

Here is my current code:

'***
Range(Cells(3, 5), Cells(500, 55)).Select

Selection.Sort Key1:=Range(Cells(3, 5), Cells(3, 55)),
Order1:=xlAscending,_ Header:=xlGuess, OrderCustom:=1,
MatchCase:=False, Orientation:=xlLeftToRight, _
DataOption1:=xlSortNormal
'***

The dates are in row 3 and this is the Key I want to use. The code
above works great as long as the date data is within the same month.
However, once another month of date data is inserted the sorting is
lost because Excel is sorting based on the first "dd".

I tried to use a format() statement in my sort but can't get it to
work. For example, this is what I want to do but this code does not
compile:

Selection.Sort Format(Range("E3").Value, "dd" & "mm" & " yyyy"),_
Key1:=Range(Cells(3, 5), Cells(3, 55)), Order1:=xlAscending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlLeftToRight,
_
DataOption1:=xlSortNormal

I've tried several iterations of the above code with no luck. I'm
hoping there is an easy way to do this without re-arranging the date
data in row 3.

thanks for you help...

~Tom
 
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 dates Bernie Deitrick Excel Programming 0 March 24th 09 05:48 PM
Sorting dates Goyo el Noyo Excel Discussion (Misc queries) 0 January 3rd 08 09:08 PM
Sorting Dates Murray Excel Discussion (Misc queries) 3 July 23rd 06 08:59 PM
Sorting Dates [email protected] Excel Worksheet Functions 1 October 6th 05 11:19 PM
Sorting dates Herb Excel Worksheet Functions 3 October 30th 04 01:22 AM


All times are GMT +1. The time now is 08:14 AM.

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

About Us

"It's about Microsoft Excel"