I have two columns with numbers. I would like to calculate in a separate cell a sum. The sum will include the minimums of corresponding cells in these two columns.
Example:
A | B
--------
[1] 1 | 2
[2] 4 | 3
[3] 0 | 1
[4] 5 | 5
I need a formula that would calculate in a cell the sum of 1 + 3 + 0 + 5 where
* 1 is the MIN(A1,B1),
* 3 is the MIN(A2,B2)
* 0 is the MIN(A3,B3)
* 5 is the MIN(A4,B4)
Is that possible in a single formula (independent of #rows)?
Working with LibreOffice Calc at the moment, but Excel solutions more than welcome.
You can use an array formula (doc for Libre Office and for Excel) for this:
Confirm by
Ctrl
+Shift
+Enter
instead of simple Enter.Well, you can do this with a formula but it's not very scalable. For example, you can do this:
that will work in the case you described. However, I appreciate that if you have a large number of rows then this won't scale nicely. In that case, I think you'll need a VBA macro as I can't see a way to do this. I'm prepared to be corrected though by some Excel formula guru.
For a VBA solution, you can try the following (found in the OzGrid forums):
When set to
TRUE
, the optional parameter calculates the minimums as opposed to the maximums that this macro calculates by default. In your example, you would need to call it like this:Just remember you need to place the code in a standard code module.