Sort more than 3 columns + choose ascending or descending

N

Nader

Hello,

I have a small problem ... I would like to sort more than 3 columns
(actually as much as I want) in excel using vba programming. In the same, I
would need to be able to choose if a column should be sorted ascending or
descending.

I already found a solution on the internet for sorting more than 3 columns :
it's to concatenate all the columns I want to sort and then sort that
columns but in that case I cannot choose to sort each column ascending or
descending....

Thanks in advance for your help.

Nader
 
N

Niek Otten

Hi Nader,

From Excel online Help:

Sort rows by four criteria (columns)
1.. Click a cell in the range you want to sort.
2.. On the Data menu, click Sort.
3.. In the first Sort by box click the column of least importance.
4.. Click OK.
5.. On the Data menu, click Sort.
6.. In the Sort by and Then by boxes, click the other three columns you want to sort, starting with the most important.
7.. Select any other sort options you want, and then click OK.
Record these actions in a macro and change where necessary

--
Kind regards,

Niek Otten
Microsoft MVP - Excel

| Hello,
|
| I have a small problem ... I would like to sort more than 3 columns
| (actually as much as I want) in excel using vba programming. In the same, I
| would need to be able to choose if a column should be sorted ascending or
| descending.
|
| I already found a solution on the internet for sorting more than 3 columns :
| it's to concatenate all the columns I want to sort and then sort that
| columns but in that case I cannot choose to sort each column ascending or
| descending....
|
| Thanks in advance for your help.
|
| Nader
|
|
 
N

Nader

Hi Niek,

Thank you for taking time to reply to my post but unfortunately it only
works for 4 columns.
In my case, I need to sort more than 3 columns but that I mean that one time
it could be 3 columns another time 10 columns. So, I was looking for
something flexible in vba or excel formula ...

Thanks a lot.
 
D

Dave Peterson

You can sort by as many columns as you want--just 3 at a time.

In xl2003, you can apply data|filter|autofilter to the range and use the
dropdown arrow to sort your data.

Debra Dalgleish has a technique at her site that adds invisible rectangles in
the headers and then sorts the data by that field when you click on one of those
rectangles.

http://contextures.com/xlSort02.html

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top