Solving one problem on another forum, I must admit, I lost my temper. The number of errors in LO Calc is simply off scale, the system is extremely unstable compared to Excel. Even the `End`

statement doesn’t help. All bugs are somewhere deep inside. Or am I doing something wrong?

LO Calc API is not used in macros. Differences from Excel can only be in the indices of the boundaries of the arrays passed to the function. Not tested.

The app **crashes** from time to time, but not always when I try to edit data (player points).

Whoever has a desire, dig into this example:

players-and-points (2) (1).ods (32.9 KB)

**Description**:

I find the next winner of the week (GetNextWinner) who has the best points scored (SortDataArrayDesc) and he - the player - wins for the first time (Not WinnerExists, skips the winners even if they have more points, it doesn’t matter).

Function **GetNextWinner**(Players, Points, Winners)

Function **SortDataArrayDesc**(DataArray()) 'simple bubble sort is used

Function **WinnerExists**(Winners, Player) As Boolean

In my example, there are 15 players (“Team1” sheet), and in the first 15 games the players are not repeated. Then the player with the maximum result is simply taken. However, according to the author’s condition, the number of players (40 or 15-20) is equal to or greater than the number of games (15-20).

So in the example, look at the first 15 games where the winners are unique. If the number of points is the same for several players, then the first unique player is displayed in the order of their sequence.

Of course, bubble sort can be replaced with more efficient sort. It is not important here.

There are several teams. In the example, there are 2 of them (Team 1 & Team 2).

All formulas on all sheets are the same and can be freely transferred from sheet to sheet. However, they all belong to their ranges, which must be set correctly. For example, I copied the Player 12 formula from the first sheet and pasted it in place of Player 21 on the second sheet. Everything works. Convenient.

Note: @Lupp & @Villeroy took an active part in this task. But everything is not easy.

Version: 7.2.0.4 / LibreOffice Community Build ID: ce769e3009755dcf0082844e386f5dca4c8ecb2f CPU threads: 8; OS: Linux 4.15; UI render: default; VCL: gtk3 Locale: ru-RU (ru_RU.UTF-8); UI: en-US Calc: threaded

**UPDATED**:

See the “players-and-points (3).ods” file attached below. Works fine, but w/o conditional formatting.

**UPDATED**:

The initial file “players-and-points (2) (1).ods” was updated. The **Iterative References** option was unchecked. Fixed one reference to the range.