+ Reply to Thread
Results 1 to 4 of 4

Column sorting

  1. #1
    ukyob
    Guest

    Column sorting

    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


  2. #2
    Tom Hutchins
    Guest

    RE: 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
    >


  3. #3
    ukyob
    Guest

    RE: Column sorting



    "Tom Hutchins" wrote:

    > 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
    > >

    Thanks for the info. Hutch. I need to explain that I am not well versed in
    Excel therefore I really do not know how to use the formula you provided.
    Can you start me off? Better yet can you provide me with an excel
    spreadsheet with examples and all I have to do is substitute my information.
    My e-mail is obie2@optonline.net
    Thanks again for your effort and time.

  4. #4
    ukyob
    Guest

    RE: Column sorting



    "ukyob" wrote:

    >
    >
    > "Tom Hutchins" wrote:
    >
    > > 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
    > > >

    > Thanks for the info. Hutch. I need to explain that I am not well versed in
    > Excel therefore I really do not know how to use the formula you provided.
    > Can you start me off? Better yet can you provide me with an excel
    > spreadsheet with examples and all I have to do is substitute my information.
    > My e-mail is obie2@optonline.net
    > Thanks again for your effort and time.


    Thanks for the reply. I should have known that the formula was a macro. I
    just was not thinking. The program works beautifully. Thanks again for your
    time and effort.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1