+ Reply to Thread
Results 1 to 5 of 5

how do you auto sort based on certain column

Hybrid View

  1. #1
    Registered User
    Join Date
    08-19-2010
    Location
    new york
    MS-Off Ver
    Excel 2010
    Posts
    97

    how do you auto sort based on certain column

    Hi,
    i'm looking to auto-sort a worksheet based on column AY. i know i could use the sort button, but i'm not the one using the sheet, and it would be easier for the person using it to be able to click a macro that sorts by column AY with one click of a button. Macros are not my strong-suit, can someone provide the code?

    thanks so much.
    Last edited by juniperjacobs; 09-20-2010 at 09:24 AM. Reason: solved.

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,487

    Re: how do you auto sort based on certain column

    What's the Range?

  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,958

    Re: how do you auto sort based on certain column

    Maybe:

    Sub Button1_Click()
    With ActiveWorkbook.Worksheets("Sheet1").Sort
        .SortFields.Clear
        .SortFields.Add _
            Key:=Range("AY:AY"), _
            SortOn:=xlSortOnValues, _
            Order:=xlAscending, _
            DataOption:=xlSortNormal
        .SetRange Range("AY:AY")
        .Header = xlYes
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
    End With
    End Sub

    Regards

  4. #4
    Registered User
    Join Date
    08-19-2010
    Location
    new york
    MS-Off Ver
    Excel 2010
    Posts
    97

    Re: how do you auto sort based on certain column

    it would be columns A2:AZ2 based on AY2.

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,958

    Re: how do you auto sort based on certain column

    Change this:

    .SetRange Range("AY:AY")

    to this:

    .SetRange Range("A:AZ")


    Regards

+ 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