ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Macro with custom sort order (https://www.excelbanter.com/excel-worksheet-functions/215379-macro-custom-sort-order.html)

Erin

Macro with custom sort order
 
I'm having trouble with the code for a macro that needs a custom sort order
for the second sort key.

I have three sort keys -- the first and third are regular sorts, but the
second needs to sort by custom list 6. Does anyone know how to do this?



Bernard Liengme

Macro with custom sort order
 
Are you using the Excel Sort feature or does your macro include a sort
algorithm?
If the later: add a table into the code like this
Red 1
Blue 2
Green 3
Now use the number in the second column as a sorting proxy for the value in
the first column
best wishes
--
Bernard V Liengme
Microsoft Excel MVP
http://people.stfx.ca/bliengme
remove caps from email

"Erin" wrote in message
...
I'm having trouble with the code for a macro that needs a custom sort
order
for the second sort key.

I have three sort keys -- the first and third are regular sorts, but the
second needs to sort by custom list 6. Does anyone know how to do this?





Dave Peterson

Macro with custom sort order
 
If you use xl2003 and try to do this manually, you'll see that you can only
specify the primary key for the custom sort order.

You could do multiple sorts, though.

One sort by the 2nd and 3rd key, then one more sort for the 1st key.



Erin wrote:

I'm having trouble with the code for a macro that needs a custom sort order
for the second sort key.

I have three sort keys -- the first and third are regular sorts, but the
second needs to sort by custom list 6. Does anyone know how to do this?


--

Dave Peterson

Erin

Macro with custom sort order
 
Thanks so much -- this worked perfectly!

"Dave Peterson" wrote:

If you use xl2003 and try to do this manually, you'll see that you can only
specify the primary key for the custom sort order.

You could do multiple sorts, though.

One sort by the 2nd and 3rd key, then one more sort for the 1st key.



Erin wrote:

I'm having trouble with the code for a macro that needs a custom sort order
for the second sort key.

I have three sort keys -- the first and third are regular sorts, but the
second needs to sort by custom list 6. Does anyone know how to do this?


--

Dave Peterson


Erin

Macro with custom sort order
 
Thanks for your response, but I did get it to work with the first
recommendation.

"Bernard Liengme" wrote:

Are you using the Excel Sort feature or does your macro include a sort
algorithm?
If the later: add a table into the code like this
Red 1
Blue 2
Green 3
Now use the number in the second column as a sorting proxy for the value in
the first column
best wishes
--
Bernard V Liengme
Microsoft Excel MVP
http://people.stfx.ca/bliengme
remove caps from email

"Erin" wrote in message
...
I'm having trouble with the code for a macro that needs a custom sort
order
for the second sort key.

I have three sort keys -- the first and third are regular sorts, but the
second needs to sort by custom list 6. Does anyone know how to do this?







All times are GMT +1. The time now is 08:15 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com