Editing old Excel macro in CALC

For M$ Excel, I was given the following macro code a couple years ago. I no longer have access to Excel and am now using LibreOffice. But, my spreadsheet page with the code just says #MACRO? when it should display the top three (3) point earners and their respective total points. In the attached screenshot, it should return the following:

1ST William 25
2ND Andrew 20
3RD Brian 20

The original Excel macro code I was given is:

=TAKE(SORT(HSTACK(UNIQUE($J$2:$J$27),SUMIF($J$2:$J$27,UNIQUE($J$2:$J$27),$K$2:$K$27)),2,-1),3)

When I open the .xls file in LibreOffice, the code has the following:

{=_xlfn.TAKE(_xlfn._xlws.SORT(_xlfn.HSTACK(_xlfn.UNIQUE($J$2:$J$27),SUMIF($J$2:$J$27,_xlfn.UNIQUE($J$2:$J$27),$K$2:$K$27)),2,-1),3)}

I am not proficient in spreadsheets. And I’m in a bit of a time crunch so I can’t just go teach myself macros etc. I can’t even edit it because it tells me “You cannot change only part of an array.” I have no idea how to edit this … or re-create it … etc. I don’t even know which cells to grab to do any of these things. Ugh. I feel stupid. Can anyone just knock it out for me … and tell me exactly what I need to do?

1 Like

May I suggest to upload the complete file, not only a screenshot. It would make testing much easier…

what I see is “only” a formula, but ok array-functions do some magic things…

This is a bit unusual, because one would usually start with a list of players (not shown in the screenshot).
If I have this list one can find the earned points for each player and continue from there.
If you don’t have the list, you need to create a list of all occuring names first (that’s the use of the UNIQUE-part) and use this as starting point.

1 Like

I just found this forum today and didn’t realize I could upload an XLS file. Does this help? The names in Column J will change whenever new games are completed; they’ll be manually typed in. So the names can and will always be a little different whenever this sheet is needed. The points (for now) are not going to change. I’m looking for something that’ll automatically determine the top three (3) ENTRANTs by their cumulative POINTS earned.
POINTS.xls (19.5 KB)

works
ask134680.ods (19.7 KB)

with LO26.2.2
but anyway instead this errorprone Formula I would prefer a simple Pivottable:
ask134680_by_pivot.ods (20.2 KB)

4 Likes

Function names with the _xlfn. prefix are already contained in your POINTS.xls file.
The .xls format is legacy and does not support “new” Excel functions.

1 Like

The first one “works” as needed for me. I was able to open the file and copy/paste into my (old) XLS spreadsheet. Thanks!