Sabtu, 07 Januari 2012

Re: [ExcelVBA] Sorting in VBA

 

> I don't think the sort there actually can be altered to cope
> with multiple keys

The sort I pointed to uses a function called QSortCompare to compare the
candidate values. As such, you simply need to change all calls to that
function send it the correct key information (either by concatenation or
multiple parameters) and amend the function as needed to check any extra
keys if you don't use concatenation in the call.

Should be straightforward enough.

> Maybe there's a misunderstanding of "keys" here.

No, no misunderstanding.

> The reason for the project is not to sort *in* an
> application but to sort items from the VBE.

Yes, we see that, but why? Both Excel and Access have excellent - and
fast - sort capabilities. Why would you use a much slower sort method in
VBA when these capabilities are around?

If you do ever need to sort in applications that don't have sort
capabilities, then fine, but there's no point in ignoring perfectly good,
efficient, and well-understood capabilities in the other applications when
they are immediately available.

Regards, Dave S

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

>
>>The first hit www.cpearson.com/excel/qsort.htm is a comprehensive sort
>>algorithm
> that is intended to be general-purpose and contains lots of comments to
> describe
> what it's doing.
> I know about Chips site and use code from there.. credited of course... a
> lot.
> I don't think the sort there actually can be altered to cope with multiple
> keys... If you have an idea how then I'd be *very* appreciative to know
> how.
>
> Maybe there's a misunderstanding of "keys" here. I want to sort an array
> on different elements in it so that the results are the same as would be
> returned by excel if sorted on multiple columns.
>
> The reason for the project is not to sort *in* an application but to sort
> items from the VBE.
>
>>I very much doubt that you will be able to find general-purpose code that
>>will
> handle the dimensions of your array, plus your requirement for many keys.
> That has been the case so far... and is what I've been looking for.
>
> Hugs...
> Lisa
>
> -----Original Message-----
> From: David Smart <smartware.consulting@gmail.com>
> To: ExcelVBA <ExcelVBA@yahoogroups.com>
> Sent: Fri, Jan 6, 2012 9:47 pm
> Subject: Re: [ExcelVBA] Sorting in VBA
>
>
>>>The use of multiple sort keys in a sort will depend entirely on the code
>>>you
> are using.
> Wel.... er ... yes... it would wouldn't it... :-)
> Yes it does and your message read as though you already had sort code but
> needed
> o make it work with multiple keys.
>> No got anything working at all yet Dave.
> Don't care whether it's working or not, but need to know what code you're
> ooking at.
>> I've spent quite some days scouring the internet for examples and not
>> found
> nything suitable.
> I don't know what you've been searching. I just did a search on: vba sort
> lgorithm
> The first hit www.cpearson.com/excel/qsort.htm is a comprehensive sort
> algorithm
> hat is intended to be general-purpose and contains lots of comments to
> describe
> hat it's doing. It currently only works off a single key, but that could
> be a
> oncatenated key. Alternatively, it could easily be modified to provide
> the
> eys separately to its QSortCompare function.
> There were many other useful hits too.
> No matter what, you are going to need to tailor the code to your specific
> array.
> very much doubt that you will be able to find general-purpose code that
> will
> andle the dimensions of your array, plus your requirement for many keys.
> A
> (uick)Sort is quite small, though, and can be adapted easily enough.
> =======================
> There is the question "why bother", of course. Excel has strong sorting
> apabilities for data in worksheets, and the later Excel versions allow
> many
> ore than the 3 key limit in 2003. Access also has stong(er) sorting
> apabilities for rows out of tables.
> Don't know about Word, but I've never wanted to sort things there anyway.
> :-)
>
> egards, Dave S
>
>
>
> [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/4128 - Release Date: 01/07/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