Consulting

Results 1 to 4 of 4

Thread: Sort

  1. #1
    VBAX Contributor
    Joined
    May 2007
    Posts
    128
    Location

    Sort

    Reference: http://www.excelforum.com/showthread.php?t=602533

    Dear Experts

    I want to sort following data on NAME in Ascending order

    Name---- Code -----Path
    Eric ------- 35 ------- A
    John ------ 22 ------- B
    Putan ----- 18 ------- D
    Tony ------ 39 ------- C

    With VBA Codes I want to sort sheet which has only three columns as mentioned.

    Please help

  2. #2
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    I got this using the macro recorder but it works:
    [VBA]Sub Macro1()
    Cells.Select
    Selection.Sort Key1:=Range("A2"), Order1:=xlAscending, Header:=xlGuess, _
    OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
    DataOption1:=xlSortNormal
    Range("E18").Select
    End Sub[/VBA]
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  3. #3
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    If you're using Excel 2000 or earlier, delete this from Steve's code
    ", _ DataOption1:=xlSortNormal "
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    In fact delete it anyway, it is the default, so makes no difference in 2003 anyway (here).
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

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