+ Reply to Thread
Results 1 to 9 of 9

4 column sort... Fools rush in....

Hybrid View

  1. #1
    Myrna Larson
    Guest

    Re: 4 column sort... Fools rush in....

    Did you try looking at Help for Sort? It works the same way in VBA as it does
    when invoked from the Data menu.

    On Thu, 3 Feb 2005 21:19:02 -0800, Neal Zimm <nealzimm@yahoo.com> wrote:

    >Not knowing any better, I took the recorded code for a 3 column sort and
    >tried to turn it into a 4 column sort. Got run time 1004 object error. Code
    >is below.
    >
    >Is it possible to do what I'm trying this way? I'd rather not have to select
    >different ranges of cells and do a 3 column sort, but I may have to.
    >So, have I made an error in the code, or is it just not possible?
    >Thanks.
    >
    >
    >Sub zsortbcda()
    >Application.ScreenUpdating = False
    >
    > Columns("A:D").Select
    >
    > Selection.Sort Key1:=Range("B1"), Order1:=xlAscending, _
    > Key2:=Range("C1"), Order2:=xlAscending, _
    > Key3:=Range("D1"), Order3:=xlAscending, _
    > Key4:=Range("A1"), Order4:=xlAscending, _
    > Header:=xlGuess, OrderCustom:=1, MatchCase:=False,
    >Orientation:=xlTopToBottom, _
    > DataOption1:=xlSortNormal, DataOption2:=xlSortNormal, _
    > DataOption3:=xlSortNormal, DataOption4:=xlSortNormal
    >
    > Range("A1").Select
    >
    >Application.ScreenUpdating = True
    >End Sub



  2. #2
    Neal Zimm
    Guest

    Re: 4 column sort... Fools rush in....

    Thanks. Help only mentions 3 columns too.
    What I ended up doing is that the data allowed me to concatenate two of the
    fields into one, so I could sort on 4 fields worth of data in "3" columns.


    "Myrna Larson" wrote:

    > Did you try looking at Help for Sort? It works the same way in VBA as it does
    > when invoked from the Data menu.
    >
    > On Thu, 3 Feb 2005 21:19:02 -0800, Neal Zimm <nealzimm@yahoo.com> wrote:
    >
    > >Not knowing any better, I took the recorded code for a 3 column sort and
    > >tried to turn it into a 4 column sort. Got run time 1004 object error. Code
    > >is below.
    > >
    > >Is it possible to do what I'm trying this way? I'd rather not have to select
    > >different ranges of cells and do a 3 column sort, but I may have to.
    > >So, have I made an error in the code, or is it just not possible?
    > >Thanks.
    > >
    > >
    > >Sub zsortbcda()
    > >Application.ScreenUpdating = False
    > >
    > > Columns("A:D").Select
    > >
    > > Selection.Sort Key1:=Range("B1"), Order1:=xlAscending, _
    > > Key2:=Range("C1"), Order2:=xlAscending, _
    > > Key3:=Range("D1"), Order3:=xlAscending, _
    > > Key4:=Range("A1"), Order4:=xlAscending, _
    > > Header:=xlGuess, OrderCustom:=1, MatchCase:=False,
    > >Orientation:=xlTopToBottom, _
    > > DataOption1:=xlSortNormal, DataOption2:=xlSortNormal, _
    > > DataOption3:=xlSortNormal, DataOption4:=xlSortNormal
    > >
    > > Range("A1").Select
    > >
    > >Application.ScreenUpdating = True
    > >End Sub

    >
    >


+ 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