Re: custom sort

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



It seems weird to me, too.

Without knowing the real reason, I think it's because two different programmers
(or two different teams of programmers or even one person at different times!)
didn't really talk to each other.

VBA's help (xl2003) for Sort shows this for ordercustom:

OrderCustom Optional Variant. This argument is a one-based integer offset to
the list of custom sort orders. If you omit OrderCustom, a normal sort is used.

But I think that this just documents how it was implemented. My guess (and it's
just a guess) is that the sort programmer expected the custom list programmer to
use 0 based stuff. And the sort programmer wanted to index starting at 0+1, but
then saw how his portion had to work.

It was too late in the development cycle (or too many versions of excel were
already in used) to go back and "fix" the problem. So the solution was to
document it in the Help. And that made it a documented feature, not a
problem/bug/error.

But that's just a guess!

And you could go to some trouble by building a two column table -- on column for
the value and one for the order. Then use =vlookup() to return that order and
sort by the helper column.

But that's way too much work!

And since it's something I never remember (and I bet you won't either <bg>),
document your code so that if you need to do it again and find this macro, you
won't have to scratch your head again (or test until you see the solution!).

Dave wrote:

Hi,
XL2003
I was hoping someone could shed some light on this for me.
In the following code, notice that I had to use "n+1" to make it work when
sorting, but just n to delete the custom list.
When I look at the custom list in Tools,Options, I see:

NEW LIST
Mon, Tue, Wed, etc
Monday, Tuesday, Wednesday, etc
Jan, Feb, Mar, etc
January, February, March, etc

For some reason, when actually using the custom list,
XL seems to be counting the "NEW LIST" as number 1, but not so when deleting
or when getting the custom list number.

Application.AddCustomList Array("T", "B", "E")
n = Application.GetCustomListNum(Array("T", "B", "E"))

Range(z).Sort _
Key1:=Range("C2"), Header:=xlNo, OrderCustom:=n + 1

Application.DeleteCustomList n

Is there a way to sort, according to a custom list, without actually
creating an official custom list?
I tried:
Range(z).Sort _
Key1:=Range("C2"), Header:=xlNo, OrderCustomArray("T", "B", "E")
but it gave an error.

Regards - Dave.

--

Dave Peterson
.



Relevant Pages

  • Re: "Sorting" assignment
    ... is the fastest possible way of exchanging two ... implement the exchange in a sort. ... In your Employee example, you never have to copy actual class ... programmer reasons that if his code is doin' a lotta data movin' (like ...
    (comp.programming)
  • Re: custom sort
    ... "Dave Peterson" wrote: ... Without knowing the real reason, I think it's because two different programmers ... VBA's help for Sort shows this for ordercustom: ... just a guess) is that the sort programmer expected the custom list programmer to ...
    (microsoft.public.excel.programming)
  • Re: Implementing strstr
    ... photographed on a motorcycle in his first book) used to give guys like ... Dweebach swirlies, noogies, and Indian burns, and guys like Dweebach ... competent programmer would not dare post here. ... of some sort for Linux, which is contradictorily marked as copyright ...
    (comp.lang.c)
  • Re: ways to update PS files?
    ... method you can even do random access I/O operations. ... multi-user access (without some sort of higher level manager) would ... And finally, if it is an application programmer type asking, the ... Behalf Of john gilmore ...
    (bit.listserv.ibm-main)
  • DFSORT - simple formula for SORTWKn size?
    ... allocate the SORTWKnn datasets dynamically. ... From my looking, SORT ... ICE084I 0 EXCP ACCESS METHOD USED FOR SORTOUT ... explanation to the programmer who was the one that started me up on this ...
    (bit.listserv.ibm-main)