If cell A val greater than cell B then, store cell val A into cell B

I am new to Libre Calc. Tried IF function to do this but I was not successful

Intent;
If cell B12 val greater than cell C12 then, store cell val B12 into cell C12.

My trial test
Cells B12 and C12 were formatted as currency.
Set value of B12 to be > C12.
Tried =IF(B12>C12,B12). IF function defined into Cell C12
Result → C12 stored $0
Other variations were also tried with various error codes.
Tried =IF(B12>C12,C12=B12) and etc…

Obviously I misunderstood what looked to be similar examples I thought might have worked that I found in other areas of the Libre Office helpfiles.

Any help to clarify my ignorance would greatly be appreciated!
Thanks in advance for considering my question.

It is not possible when the B12 and C12 are manually inserted constant values. In this case you need use more one cell to store the selection IF() formula, and you must use that result for the other calculations.
.
But when the C12 is a calculated value by some formula, then it is possible. In the C12:

=IF(B12 > your formula; B12; your formula)

Please upload your ODF type sample file here.

Your attemp is comparable to procedural programming like BASIC or C, Pascal etc. But Calc is more a declarative system. You put a formula in a cell, wich gives a result like =B12+C12 to sum your two cells. But you can’t put this formula in C12, as this cell already holds one value of the sum, and you can’t put 2 things in the same cell (OK, later you will see you can, but let’s ignore formatting and images for now.) So you could put the formula in D12 and all is fine.
.
In the same way you can put a copy of the greater value in D12 with =IF(B12>C12;B12;C12) but not in B12 or C12

Try =MAX(C12;B12) instead =IF() in D12 - does the same but is written much shorter.

1 Like