Thread: Column sorting
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Tom Hutchins Tom Hutchins is offline
external usenet poster
 
Posts: 1,069
Default Column sorting

Try this:

Sub ABCDEF()
'Set the two columns here as Col1 and Col2
Const Col1 = "A"
Const Col2 = "B"
Dim LastRow As Long, NextRow As Long
LastRow& = Range(Col2 & Rows.Count).End(xlUp).Row
NextRow& = Range(Col1 & Rows.Count).End(xlUp).Row + 1
Range(Col2 & "1:" & Col2 & LastRow&).Cut _
Destination:=Range(Col1 & NextRow&)
Range(Col1 & NextRow&).Select
Columns(Col1 & ":" & Col1).Select
Selection.Sort Key1:=Range(Col1 & "1"), Order1:=xlAscending, _
Header:=xlNo, OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom, DataOption1:=xlSortNormal
LastRow& = Range(Col1 & Rows.Count).End(xlUp).Row
Range(Col1 & (CInt(LastRow& / 2) + 1) & ":" & Col1 & LastRow&).Cut _
Destination:=Range(Col2 & "1")
Range(Col2 & "1").Select
End Sub

No provision was made for column headings.

Hope this helps,

Hutch

"ukyob" wrote:

I want to be able to re-sort two columns of information every time I make a
new entry. I want it to start in alphabetical order in the first column and
finish off evenly in the second. ex:

column A Column B
a e if I make an entry to column
A (f), I want the
b g program to sort it and place
it in column B
c h between the e and g. It
needs to resize the
d columns and make both column
entries equal.
f