View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Sort more than 3 columns + choose ascending or descending

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

Nader wrote:

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.

"Niek Otten" a écrit dans le message de news:
...
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

"Nader" wrote in message
...
| 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
|
|



--

Dave Peterson