+ Reply to Thread
Results 1 to 6 of 6

Macro to sort column in activesheet

  1. #1
    Registered User
    Join Date
    01-20-2012
    Location
    san jose
    MS-Off Ver
    Excel 2007
    Posts
    8

    Macro to sort column in activesheet

    I am trying to sort a column in the active worksheet. My macro sorts the column, but does not expand to include the rest of the table. Need help!

    ' sort_date in Active Worksheet Macro
    '

    Columns("E:E").Select
    ActiveWorkbook.ActiveSheet.Sort.SortFields.Clear
    ActiveWorkbook.ActiveSheet.Sort.SortFields.Add Key:=Range("E:E") _
    , SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
    With ActiveWorkbook.ActiveSheet.Sort
    .SetRange Range("A2:Q100")
    .Header = xlGuess
    .MatchCase = False
    .Orientation = xlTopToBottom
    .SortMethod = xlPinYin
    .Apply
    End With

  2. #2
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Macro to sort column in activesheet

    Try this one

    change
    Please Login or Register  to view this content.

    in
    Please Login or Register  to view this content.
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  3. #3
    Registered User
    Join Date
    01-20-2012
    Location
    san jose
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Macro to sort column in activesheet

    no.. it didn't work. It still sorted just the column

  4. #4
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Macro to sort column in activesheet

    This recorded macro sort the column E in the range A:F

    You have to change the range E2:E9 if you have more row in your data.

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    01-20-2012
    Location
    san jose
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Macro to sort column in activesheet

    I don't know what is wrong, it still doesn't work.

  6. #6
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Macro to sort column in activesheet

    And you have tried my solution in #4?

    I tested it, and for me it works.

+ 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