Changing the Sum Range

G

Guest

I have an "array formula" that uses multiple criteria to do mimic a "SUMIF"
with more than one possible criteria.

Essentially it is {SUM(IF((C3:C15<>"X")*(C3:C15<>"Y"),1,0)*(D3:D15))}

I want to change the sum range (that is, the (D3:D15)) dependent on some
variable. That is, sometimes I want it to use E3:E15 or K3:K15. Is there an
easy way to do this?

Thanks!
 
R

Rodrigo Ferreira

Try something like this

SUMPRODUCT( (C3:C15<>"X")* (C3:C15<>"Y"), OFFSET(C3;;D1;13))

where 13 is the number of cells you want to sum

where D1 is the number of the column (after C) you want to sum.
eg.:
if D1 = 1, will sum D3:D15
if D1 = 8, will sum K3:K15


If you want everything in variables, try this:

SUMPRODUCT( (OFFSET(C3;;C1;13)<>"X")* (OFFSET(C3;;C1;13)<>"Y"),
OFFSET(C3;;D1;13))
where C1 is the number of the column (after C) you want to compare.
eg.:
if C1 = 0, will check C3:C15
if C1 = 2, will check E3:E15
 
B

Bruno Campanini

mcleester said:
I have an "array formula" that uses multiple criteria to do mimic a "SUMIF"
with more than one possible criteria.

Essentially it is {SUM(IF((C3:C15<>"X")*(C3:C15<>"Y"),1,0)*(D3:D15))}

I want to change the sum range (that is, the (D3:D15)) dependent on some
variable. That is, sometimes I want it to use E3:E15 or K3:K15. Is there
an
easy way to do this?

{=SUM((C3:C15<>"X")*(C3:C15<>"Y")*(D3:D15))}
FormulaArray

{=SUM((C3:C15<>"X")*(C3:C15<>"Y")*INDIRECT(B3&"3:"&B3&"15"))}
FormulaArray, having in B3: D | E | K | ...

Bruno
 
B

Bruno Campanini

{=SUM((C3:C15<>"X")*(C3:C15<>"Y")*(D3:D15))}
FormulaArray

{=SUM((C3:C15<>"X")*(C3:C15<>"Y")*INDIRECT(B3&"3:"&B3&"15"))}
FormulaArray, having in B3: D | E | K | ...

Bruno

You can avoid FormulaArray mode replacing SUM with
SUMPRODUCT.

Bruno
 
G

Guest

That works great! Muito obrigado.

Rodrigo Ferreira said:
Try something like this

SUMPRODUCT( (C3:C15<>"X")* (C3:C15<>"Y"), OFFSET(C3;;D1;13))

where 13 is the number of cells you want to sum

where D1 is the number of the column (after C) you want to sum.
eg.:
if D1 = 1, will sum D3:D15
if D1 = 8, will sum K3:K15


If you want everything in variables, try this:

SUMPRODUCT( (OFFSET(C3;;C1;13)<>"X")* (OFFSET(C3;;C1;13)<>"Y"),
OFFSET(C3;;D1;13))
where C1 is the number of the column (after C) you want to compare.
eg.:
if C1 = 0, will check C3:C15
if C1 = 2, will check E3:E15
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top