Consulting

Results 1 to 4 of 4

Thread: Sorting through two lists

  1. #1

    Sorting through two lists

    Hey everyone.

    Im trying to sort information through one column first then the second column. Eg:

    1 2
    1 3
    2 2
    1 1
    2 1

    should be

    1 1
    1 2
    1 3
    2 1
    2 2

    but its

    1 2
    1 3
    1 1
    2 2
    2 1

    Im using:

    Range(Cells(2, 1), Cells(8, 8)).Sort Key1:=Cells(2, 1)

    at the moment.

    Any help greatly appreciated.

  2. #2
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    You just left out the second sort key. Try:

    [VBA]Range(Cells(2, 1), Cells(8, 8)).Sort Key1:=Cells(2, 1), Key2:=Cells(2, 2)[/VBA]

    Mark

  3. #3
    Thanks Mark, you're a legend!

  4. #4
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    Me? Not even close, more at, "hey, I think I got that one right!"

    Thanks though and happy to help,

    Mark

Posting Permissions

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