Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 70
Default Sort The Date at the center of string with VBA

Hi, I need to sort date ascending or descending but the problem now the date location at the center or string for example 09-02-18012013-86653-A where the date is 18012013. This data at column A where column B to G got other data.Anyone here got idea how to do it with VBA. Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,872
Default Sort The Date at the center of string with VBA

Hi,

Am Wed, 13 Feb 2013 06:19:01 -0800 (PST) schrieb geniusideas:

Hi, I need to sort date ascending or descending but the problem now the date location at the center or string for example 09-02-18012013-86653-A where the date is 18012013. This data at column A where column B to G got other data.Anyone here got idea how to do it with VBA. Thanks


with helper column in H (suit if you have headers):

Sub SortDate()
Dim LRow As Long
Dim intD As Integer, intM As Integer, intY As Integer
Dim rngC As Range

LRow = Cells(Rows.Count, 1).End(xlUp).Row
For Each rngC In Range("A1:A" & LRow)
intD = Mid(rngC, 7, 2)
intM = Mid(rngC, 9, 2)
intY = Mid(rngC, 11, 4)
rngC.Offset(0, 7) = DateSerial(intY, intM, intD)
Next
Range("A1:H" & LRow).Sort key1:=Range("H1"), _
order1:=xlAscending, Header:=xlNo
Columns("H").ClearContents

End Sub


Regards
Claus Busch
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2
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
Build a String Sort Key, sort a 2 dimen array Mar20 Neal Zimm Excel Programming 1 March 21st 10 04:51 AM
Merge and Center and Center Accross Selection Bojingles03 New Users to Excel 3 March 17th 09 07:05 PM
Retrieve Center Header String Ken Hudson Excel Programming 3 September 26th 08 07:18 PM
Center Across Selection Vertically Help. I am trying to center te. msond Excel Discussion (Misc queries) 1 March 29th 05 12:37 PM
sort (on part of) string - originally posted under Tricky Sort Tom Ogilvy Excel Programming 0 August 6th 04 02:42 AM


All times are GMT +1. The time now is 06:27 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"