Arranging dates in a single column

S

shriil

I have a data sheet where some date fields get populated as below (dd/
mm/yyyy format)
A B
03/04/2010 04/05/2010
15/05/2010 17/05/2010
20/04/2010 23/04/2010
01/06/2010 02/06/2010
12/05/2010 18/05/2010

I would like to arrange all the dates in another column, say C, but in
an ascending manner

How do I go about it?

Thanks for the help
 
D

Don Guillett Excel MVP

I have a data sheet where some date fields get populated as below (dd/
mm/yyyy format)
         A                    B
 03/04/2010         04/05/2010
 15/05/2010         17/05/2010
 20/04/2010         23/04/2010
 01/06/2010         02/06/2010
 12/05/2010         18/05/2010

I would like to arrange all the dates in another column, say C, but in
an ascending manner

How do I go about it?

Thanks for the help

Just copy each range to col c and SORT
 
S

shriil

Just copy each range to col c and SORT

Yes... I know that.. but as the data gets populated from other
worksheets and goes on increasing in subsequent rows, I would want to
avoid any manual interventions like "copying and sorting" at every
instance of a new data. Instead it would be helpful if I could run a
code which selects the range in which data is present, sorts the same
and fills it in Column C.
 
D

Don Guillett Excel MVP

Yes... I know that.. but as the data gets populated  from other
worksheets and goes on increasing in subsequent rows, I would want to
avoid any manual interventions like "copying and sorting" at every
instance of a new data. Instead it would be helpful if I could run a
code which selects the range in which data is present, sorts the same
and fills it in Column C.- Hide quoted text -

- Show quoted text -

This should do it even if there are blanks in a & b
Option Explicit
Sub copyAandBtoCandSortSAS()
Dim i As Double
For i = 1 To 2 'columns
Range(Cells(1, i), Cells(Rows.Count, i).End(xlUp)).Copy _
Cells(Rows.Count, 3).End(xlUp).Offset(1)
Next i
Columns(3).Sort Key1:=Cells(1, 3), Order1:=xlAscending, _
Header:=xlGuess, OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom, DataOption1:=xlSortTextAsNumbers
End Sub
 
S

shriil

This should do it even if there are blanks in a & b
Option Explicit
Sub copyAandBtoCandSortSAS()
Dim i As Double
For i = 1 To 2 'columns
 Range(Cells(1, i), Cells(Rows.Count, i).End(xlUp)).Copy _
 Cells(Rows.Count, 3).End(xlUp).Offset(1)
Next i
Columns(3).Sort Key1:=Cells(1, 3), Order1:=xlAscending, _
Header:=xlGuess, OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom, DataOption1:=xlSortTextAsNumbers
End Sub- Hide quoted text -

- Show quoted text -

Thanks a lot. Shall try it out and give the feedback
 
S

shriil

This should do it even if there are blanks in a & b
Option Explicit
Sub copyAandBtoCandSortSAS()
Dim i As Double
For i = 1 To 2 'columns
 Range(Cells(1, i), Cells(Rows.Count, i).End(xlUp)).Copy _
 Cells(Rows.Count, 3).End(xlUp).Offset(1)
Next i
Columns(3).Sort Key1:=Cells(1, 3), Order1:=xlAscending, _
Header:=xlGuess, OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom, DataOption1:=xlSortTextAsNumbers
End Sub- Hide quoted text -

- Show quoted text -

Thanks Don. Its works perfectly fine
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top