Sabtu, 07 Januari 2012

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]

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