--- LisaFay wrote:
> ...
> Why go from the least sig. please? It seems to me that sorting on the next least significant would destroy the sort that ...
Your last comment is the key [no pun intended].
Lisa, David, David, Paul, [pending correct understanding]
I *think* (hope) I understand this thread and Lisa's question. If I do, I believe my solution to the "Surname to Number" post by Michael T. addresses Lisa's issue; and building this concatenated 'super key' is not needed.
You do start sorting with the least significant key. Your code must leave the order of this sort unchanged **for subsequent sorts where that subsequent key is identical**.
When you do a subsequent sort and the keys are equal, do not reorder those records, move them to the new location in the existing order. This shouldn't be difficult, but I'd be hard pressed to outline it off the top of my head. Sorta' seems like a bubble sort would work, but I am not a sort algorithm expert.
This is the way the Excel sorts work. It is the way recommended (in the original uSoft Excel VBA book I have) to sort on more keys than your particular Excel has provisions for.
FWIW:
I duplicate my previous solution message (14964) here:
You use serial sorts, that is, several sorts, one after the other. You can get
the same result as later versions of Excel that have many sort keys by sorting
on the lower level column sort keys first, then sort columns, one-at-a-time
working your way up the sort key list.
Excel sorts are done in such a way that early sort order is not changed when
later sorts have matching sort keys.
Say Columns are
A = Last
B = First
C = Middle
D = Birth Date
E = Death Date
If Last names same, put in first name order. AND
If First names same, put in Middle name order, AND
If Middle names same, put in Birth Order...
He wanted people with the same First, Last and Middle names sorted by birth
date. IF they had the same Birth Date, he wanted them in order of Death Date.
So do single column sorts in this (upward) order: E, D, C, B, A.
I even took his sample data and did a sheet to demonstrate (which I did keep if
someone wants to look @ it). This sheet uses single key Excel sorts to simply demonstrate the algorithm.
Regards, Steve
P.S. If I don't understand, PLEASE ignore this post. (;-(mum)
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: http://www.mousetrax.com/techtrax to enter the ezine, then search the ARCHIVES for EXCEL VBA.
----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA
----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com
----------------------------------
Tidak ada komentar:
Posting Komentar