Question

I have an excel sheet that needs to calculate the sum of values. Values can be in one of two fields, and if it is in the second one, I want to disregard the first one.

Row1: Default value | Override Value

Row2:       1       | 2

Row 3:      4       | no value entered

Row 4:      0       | 6


Subtotal of Values=12

If Override value is populated, then include that number, and not the Default Value in the subtotal. If Override value is not populated, then include the Default value in the Subtotal.

I need to use Subtotal 109 because I have fields that are sometimes hidden.

Is it possible to do this with a formula directly within the excel spreadsheet, and not using and VBA code?

Was it helpful?

Solution 2

Like this?

=SUMIF(B1:B3,"",A1:A3) + SUMIF(B1:B3,"<>",B1:B3)

enter image description here

OTHER TIPS

To account for hidden fields as well maybe try this:

=SUMPRODUCT(SUBTOTAL(109,OFFSET(A1,ROW(A1:A3)-ROW(A1),B1:B3<>"")))

(eg hiding second row gives 8)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top