JameMeck
asked on
Excel dynamic sum.
My excel file:
DATE 1 2 3 4 5 6
TTL Cast target 1,082 2,173 1,520 2,245 2,286 2,184
My parameter: a
If a = 3 --> =sum(B2:D2)
if a = 2 --> = sum(B2:C2)
How can I do it?
DATE 1 2 3 4 5 6
TTL Cast target 1,082 2,173 1,520 2,245 2,286 2,184
My parameter: a
If a = 3 --> =sum(B2:D2)
if a = 2 --> = sum(B2:C2)
How can I do it?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Or do you want it to consider other values for a?
=IF(condition, result if true, result if false)
so, here it would be :
=IF(a=3, sum(B2:D2), IF(a=2, sum(B2:C2), 0))
if a is neither 3 or 2 then the result is 0
so, here it would be :
=IF(a=3, sum(B2:D2), IF(a=2, sum(B2:C2), 0))
if a is neither 3 or 2 then the result is 0
Where will the parameter come from
If it is in say cell a2 you could use something like
=SUM(INDIRECT(ADDRESS(1,2) ):INDIRECT (ADDRESS(1 ,2+ A2)))
Michael
If it is in say cell a2 you could use something like
=SUM(INDIRECT(ADDRESS(1,2)
Michael
=SUMIF(B1:F1,"<"&A3,B2:F2)
for example assuming your value (3 or 2 or whatever) is in A3.
for example assuming your value (3 or 2 or whatever) is in A3.
Typo:
=SUMIF(B1:F1,"<="&A3,B2:F2 )
=SUMIF(B1:F1,"<="&A3,B2:F2
...or you could use INDEX, something like
=SUM(B2:INDEX(B2:Z2,A3))
regards, barry
=SUM(B2:INDEX(B2:Z2,A3))
regards, barry