Consulting

Results 1 to 5 of 5

Thread: Easy sort question

  1. #1
    Moderator VBAX Master austenr's Avatar
    Joined
    Sep 2004
    Location
    Maine
    Posts
    2,033
    Location

    Easy sort question

    I know I have seen this before but cannot find it. The following code runs in XP but causes a compile error when run in 97. The error is on the xlSortNormal. What is the correct way to make it cross version compatable?

    Sub SortDataList() '\sorts the data list after new row is entered
         With Range("DataBase").Parent
        .Range("A2:D65536").Sort Key1:=.Range("A2"), Order1:=xlAscending, Header:=xlNo, _
         OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
         DataOption1:=xlSortNormal
        End With
    End Sub
    Peace of mind is found in some of the strangest places.

  2. #2
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    Just remove the DataOption1 Argument and it should work fine.

  3. #3
    Moderator VBAX Master austenr's Avatar
    Joined
    Sep 2004
    Location
    Maine
    Posts
    2,033
    Location
    ok thanks
    Peace of mind is found in some of the strangest places.

  4. #4
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    You're Welcome

    Take Care

  5. #5
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    This is all you need ...

    Range("DataBase").Parent.Range("A2:D65536").Sort Range("DataBase").Parent.Range("A2")
    The other stuff is default, no need to expressly call it.

Posting Permissions

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