If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > sorting data in more than 3 columns

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-10-09, 15:41
abhay_547 abhay_547 is offline
Registered User
 
Join Date: Sep 2009
Posts: 78
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.
Reply With Quote
  #2 (permalink)  
Old 09-13-09, 07:09
CasparV CasparV is offline
Registered User
 
Join Date: Jul 2007
Posts: 54
Suggestion

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.

Thanks,
Caspar
Reply With Quote
  #3 (permalink)  
Old 10-02-09, 09:08
Grinning Crow Grinning Crow is offline
Registered User
 
Join Date: Oct 2009
Posts: 8
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On