Michele Zarri wrote:
Hello All,
First of all I would like to clarify that I know I should really use base to
do what I want to do, but I am also too lazy to learn so I would like to
keep using calc... sorry!
Ok, here we go with my problem.
I have a table with some hundreds of entries one of the columns being a
numerical value.
What I would like to do is to *use a macro* to find out the top 5 values and
return the row number of those entries (which I will use for some processing
later on).
Of course, the brute force such as sticking all the values in an array, sort
it and so on does the job, but my feeling is that there must be a clever way
to do it. I noticed for example that if I enable the auto filtering on the
table I can highlight the top 10 values which is similar if not exactly to
what I need.
I was also thinking of using the built in function DMAX, but
a) how can I invoke it in a macro?
b) how can I get the second, third, fourth and fifth value?
Anyway, I hope I have been clear in explaining my problem, if not let me
know.
I am not a database expert and I am too lazy to lookup the precise
syntax, but.... Regardless, I would use SQL.
The SQL would likely look something like this:
select * from TABLE_NAME order by COLUMN_NAME desc where rownum < 6
I forget the correct syntax for limiting the number of rows... But, that
is how I would do it.... Then, the macro has to do nothing but collect
the data. The tricky part is figuring out which row number. Then again,
the important thing is NOT that you have the row number, but that you
have the primary key value so that you can easily get the values back....
--
Andrew Pitonyak
My Macro Document: http://www.pitonyak.org/AndrewMacro.odt
My Book: http://www.hentzenwerke.com/catalog/oome.htm
Info: http://www.pitonyak.org/oo.php
See Also: http://documentation.openoffice.org/HOW_TO/index.html
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]