+ Reply to Thread
Results 1 to 2 of 2

Thread: batch sort

  1. #1
    Registered User
    Join Date
    03-06-2011
    Location
    los angeles
    MS-Off Ver
    Excel 2007
    Posts
    3

    batch sort

    I have about 4000 lines of data I want to sort in columns I - M
    they are numerical from 1 to 40 and want to sort the rows left to right
    lowest to highest. I can do it individually but would like to do it a lot faster.
    if I use the the multiple "then by" boxes it still changes the first selection
    but does not do the rest instead it just does some other kind of sorting.

    Not sure what I'm missing here.

    Tried to create a macro but did not get that to work either.

    Waddaya Recon?

    G.

  2. #2
    Forum Moderator DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Suffolk, UK
    MS-Off Ver
    2002, 2007 & 2010
    Posts
    21,423

    Re: batch sort

    I think you would need to use VBA - either iterate the data set and apply the Sort on a row by row basis or push the data into an Array and sort the Array before pasting back to the sheet.

    The former is perhaps more obvious to work through and with 4000 lines of data (I:M) should not prove too slow ... in basic terms:

    Sub Example()
        Dim rngRow As Range
        On Error Resume Next
        Application.ScreenUpdating = False
        With Sheets("Sheet1")
            For Each rngRow In .Range(.Cells(2, "I"), .Cells(.Rows.Count, "M").End(xlUp)).Rows
                With rngRow
                    .Sort .Cells(1), xlAscending, Orientation:=xlSortRows
                End With
            Next rngRow
        End With
        Application.ScreenUpdating = True
    End Sub
    Modify sheet & range references etc to suit own requirements.

+ 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.2.0