Working with user-selected cells

I want the user to be able to highlight two cells in Calc (ie with Ctrl-click) and then divide the smaller value into the larger value and display the result in a third cell.

Example: if a user highlights two cells containing “3” and “12” then another cell must display “4”

Is there a function to operate on SELECTED() that I can use, or do I need a macro?

…and the next $user wants to calculate the »clausotropic foo over x v z« from a selection of four.
simply teach your user to enter:

=MAX(x;y)/MIN(x;y)

into this somehow undefined third cell.

1 Like

Let me rephrase the question. Is there a function in Calc which will return a list of highlighted cells?

No there isnt!

Ok, so I need to write a macro which will do that. Thanks.

95187.ods (18.2 KB)
or this one:
95187a.ods (17.5 KB)

No. Formulas (functions) never do such things.
They deliver results to the cells they are placed in, and need to reference the cells to work with. This is what @karolus demonstrated.

I hardly can imagine a use case.
Anyway you wouldn’t only need to select the cells containing the operands, but also to indicate the target cell. Just “another cell” may not be the one you mean.
In addition you need to handle negative numbers and the case of 0 in the role of the divisor.