Jumat, 06 Januari 2012

Re: [ExcelVBA] Re: Sorting in VBA

 

> Why go from the least sig. please? It seems to me that sorting on the
> next least significant would destroy the sort that you've just done.

You don't actually need to sort on the keys separately; you can check them
all on the same pass. It depends what type of code you're using to do your
sort.

Sorting separately from the lease significant will work provided your sort
algorithm keeps equal key items in the order it finds them. So the less
significant order will be retained for two items if all the more significant
keys are equal. However, many sort algorithms do not guarantee to retain
this order.

HOWEVER this only applies when you are sorting SEPARATELY by each key. If
you are doing the sort in one go, then your comparison does consider the
more significant keys first.

Regards, Dave S

----- Original Message -----
From: <1z@compuserve.com>
To: <ExcelVBA@yahoogroups.com>
Sent: Saturday, January 07, 2012 12:01 AM
Subject: Re: [ExcelVBA] Re: Sorting in VBA

>
> Soz for that... it got sent before I was done...
>
> David,
>
>
> So your answer is ... Yes ... depending on the delimiter?
>
>
> I've been trying to build code that sorts on the succesive keys but it's
> quite complex... and I've been sorting on the most significant key first.
>
>
> Why go from the least sig. please? It seems to me that sorting on the next
> least significant would destroy the sort that you've just done.
>
> Lisa
>
>
> Subject: [ExcelVBA] Re: Sorting in VBA
>
>
>
> Lisa --
> as your question "is contcatonating all the keys into a single field that
> is
> hen used as the sort field the same as sorting the array on each key in
> equence?" ?
> You can create a mega-key by concatonating all the keys together but you
> must
> eparate the keys by a delimiter that is not in the content of the keys.
> I use
> <tab> for this (chr(9)) since it is highly unlikely in Excel cell content.
> hus your concatonation becomes
> egakey = key1 & vbtab & key2 & vbtab .......
> you also can achieve the result by sorting the array on each key in
> sequence,
> ut you need to start with the least significant key and progress toward
> the
> ost significant key. (on columns 6, then 4, then 1, and finally 0 in your
> xample. You will also need a sort algorithm (if you are not using
> Excel's)
> hat preserves the relative order of the lower-significant keys in the case
> of a
> compare-equal' at a higher level. (If, when you are comparing on column 6
> and
> wo values are equal, your algorithm must not move the records out of order
> with
> espect to what you already determined when you sorted column 4. (If values
> are
> nequal in column 6, then the sort order in column 4 is meaningless).
> db
>
>
>
> [Non-text portions of this message have been removed]
>
>
>
> ------------------------------------
>
> ----------------------------------
> 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
>
> ----------------------------------Yahoo! Groups Links
>
>
>
>
>
> -----
> No virus found in this message.
> Checked by AVG - www.avg.com
> Version: 10.0.1416 / Virus Database: 2109/4125 - Release Date: 01/05/12
>

__._,_.___
Recent Activity:
----------------------------------
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

----------------------------------
MARKETPLACE

Stay on top of your group activity without leaving the page you're on - Get the Yahoo! Toolbar now.

.

__,_._,___

Tidak ada komentar:

Posting Komentar