Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2009

    Unanswered: sorting data in more than 3 columns

    Hi All,

    In excel we can sort max 3 columns data but can we sort multiple columns through vba code at one go. If yes, can you please provide an example

    Thanks for your help in advance.

  2. #2
    Join Date
    Jul 2007


    I don't think you can sort more than 3 columns at a time, but one way round this is to concatenate columns. It depends what data you have.

    If entries in a particular column are all the same length then great, but if the data is of variable length then you will need to add something to make them a consistent length. For numeric data, just add the value to a fixed big number (say 10000000, because then it is easy to read).

    For text data you need to add a series of spaces. One way to do this is:

    =(A1 & left(" ",(50-len(A1)))

    where A1 is the text data and there are 50 spaces between the inverted commas.

    Hope you can make something of this suggestion.


  3. #3
    Join Date
    Oct 2009
    In Excel 2007 you can sort as many columns as you like. In prior versions, do this:

    If you want to sort columns in the order A, C, F, B, I,

    Split your columns into groups of three, from the start.

    Group 1 = A, C, F
    Group 2 = B, I

    Then sort each group in reverse order. So, do the sort on group 2 first, then group 1.

    Here is a link to a knowledge base article saying the same thing:
    How to sort more than three columns in Excel

Posting Permissions

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