Consulting

Results 1 to 5 of 5

Thread: Data sort automatic??

  1. #1
    VBAX Contributor
    Joined
    Feb 2005
    Posts
    151
    Location

    Data sort automatic??

    Hi there,

    I have a doubt that I explain in the attach file, I think is a simple one....


    If any of you guys can take a look I appreciate.

    best regards,


    Ismael


  2. #2
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    Try this.

    Option Explicit
     
    Sub Sort()
    Range("B9:B20").Sort Key1:=Range("B9"), Order1:=xlAscending, Header:=xlNo, _
            OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
            DataOption1:=xlSortNormal
    Range("C9:C20").Sort Key1:=Range("C9"), Order1:=xlAscending, Header:=xlNo, _
            OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
            DataOption1:=xlSortNormal
    Range("D9:D20").Sort Key1:=Range("D9"), Order1:=xlAscending, Header:=xlNo, _
            OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
            DataOption1:=xlSortNormal
    Range("E9:E20").Sort Key1:=Range("E9"), Order1:=xlAscending, Header:=xlNo, _
            OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
            DataOption1:=xlSortNormal
    Range("F9:F20").Sort Key1:=Range("F9"), Order1:=xlAscending, Header:= _
            xlNo, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
            DataOption1:=xlSortNormal
    End Sub

  3. #3
    VBAX Contributor
    Joined
    Feb 2005
    Posts
    151
    Location
    Hi DRJ,

    Is everything ok with you?

    when I execute the macro, a message of an error appear, you can see this error in the attach file.

    thanks

  4. #4
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    I'm doing fine.

    Try this.


    Option Explicit
     
    Sub Sort()
    Range("B9:B20").Sort Key1:=Range("B9"), Order1:=xlAscending, Header:=xlNo, _
        OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
    Range("C9:C20").Sort Key1:=Range("C9"), Order1:=xlAscending, Header:=xlNo, _
        OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
    Range("D9:D20").Sort Key1:=Range("D9"), Order1:=xlAscending, Header:=xlNo, _
        OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
    Range("E9:E20").Sort Key1:=Range("E9"), Order1:=xlAscending, Header:=xlNo, _
        OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
        DataOption1:=xlSortNormal
        Range("F9:F20").Sort Key1:=Range("F9"), Order1:=xlAscending, Header:= _
        xlNo, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
    End Sub

  5. #5
    VBAX Contributor
    Joined
    Feb 2005
    Posts
    151
    Location
    Many thanks DRG,

    the macro works perfectly, I just delete one more line

    DataOption1:=xlSortNormal
    I think by mistake you left there, and now everything works nice.



    Best regards

    Ismael


Posting Permissions

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