+ Reply to Thread
Results 1 to 3 of 3

Sort Two Columns at a time

  1. #1
    Registered User
    Join Date
    12-01-2010
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2007
    Posts
    2

    Sort Two Columns at a time

    Hi all,

    I'm pretty new to macros and whilst I've had some wins so far, I've hit a brick wall and was hoping someone could translate my logic into a working macro or at least point me in the right direction.

    I have a sheet with several columns, grouped in pairs. What I want to do is sort each pair by the values in the second column.

    The columns look something like this:

    | A | B | C | D |
    | Item1 | Val_1 | Item2 | Val_2 |
    | foo | 26 | foo | 3 |
    | bar | 12 | bar | 9 |

    The pseudocode I've come up with looks like this:

    -----
    columnOne = A
    columnTwo = B

    WHILE there's still columns with values in them

    sort (columnOne:columnTwo) by columnTwo descending with headers
    columnOne+= 2 // i.e. offset 2 columns to the right C, E, H
    columnTwo+= 2 // i.e. D, F, G

    REPEAT
    -----

    I would greatly appreciate any assistance with this.

    Thanks in advance,
    Joe

  2. #2
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885

    Re: Sort Two Columns at a time

    Hi Joe, welcome to the forum.

    Perhaps the following macro will help you out..
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    12-01-2010
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Sort Two Columns at a time

    Paul,

    You're an absolute legend, mate.

    Thanks heaps for helping me out.

    Cheers,
    Joe

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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