Sum column dynamically

Multi tool use
up vote
0
down vote
favorite
Having A1+C1
and B1+D1
in two cells how can I dynamically set up a formula to catch if some column is added.
Let's say the user adds two columns in the middle. I should have A1+C1+E1
and B1+D1+F1
.
I thought it would have been automatic but it is not.
excel
add a comment |
up vote
0
down vote
favorite
Having A1+C1
and B1+D1
in two cells how can I dynamically set up a formula to catch if some column is added.
Let's say the user adds two columns in the middle. I should have A1+C1+E1
and B1+D1+F1
.
I thought it would have been automatic but it is not.
excel
If they only add one column?
– Darren Bartrup-Cook
Nov 8 at 11:35
Are the columns in between empty? And are the values text or numeric or mixture? And does it always start at column A?
– QHarr
Nov 8 at 11:42
As per your comments, their doestn't seems to be any defined logic that can be used to have the sum, (neither even/odd nor the sum()) but maybe the sum can be linked with the headers, it would be helpful if you can take a screenshot of your sheet and paste it here.
– usmanhaq
Nov 8 at 11:51
Hi usmanhaq, you are correct. All the columns follow the same logic H1,P3,L1,K2,U9 these are codes repeated for each customer so the sheet looks like: H1,P3,L1,K2,U9,H1,P3,L1,K2,U9,H1,P3,L1,K2,U9,H1,P3,L1,K2,U9...in teh second row, the first is the name of the customer. I need to sum these five code by quantity (the quanity is in the third row).
– Diegoctn
Nov 8 at 14:05
Still i would say that give a screenshot or a sample of your sheet, if your data is sensitive you can create some random figures, like customer 1 customer 2.. What i have understood with your comment may not be the actual case so it is better to be confirmed, and also let me know what would happen with these headers after a column is inserted and why it is inserted. and another thing is if you want to address someone in comments you have to write his name with @ like @Diegoctn
– usmanhaq
Nov 9 at 2:29
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Having A1+C1
and B1+D1
in two cells how can I dynamically set up a formula to catch if some column is added.
Let's say the user adds two columns in the middle. I should have A1+C1+E1
and B1+D1+F1
.
I thought it would have been automatic but it is not.
excel
Having A1+C1
and B1+D1
in two cells how can I dynamically set up a formula to catch if some column is added.
Let's say the user adds two columns in the middle. I should have A1+C1+E1
and B1+D1+F1
.
I thought it would have been automatic but it is not.
excel
excel
edited Nov 8 at 11:46


Darren Bartrup-Cook
13k11431
13k11431
asked Nov 8 at 10:40
Diegoctn
217
217
If they only add one column?
– Darren Bartrup-Cook
Nov 8 at 11:35
Are the columns in between empty? And are the values text or numeric or mixture? And does it always start at column A?
– QHarr
Nov 8 at 11:42
As per your comments, their doestn't seems to be any defined logic that can be used to have the sum, (neither even/odd nor the sum()) but maybe the sum can be linked with the headers, it would be helpful if you can take a screenshot of your sheet and paste it here.
– usmanhaq
Nov 8 at 11:51
Hi usmanhaq, you are correct. All the columns follow the same logic H1,P3,L1,K2,U9 these are codes repeated for each customer so the sheet looks like: H1,P3,L1,K2,U9,H1,P3,L1,K2,U9,H1,P3,L1,K2,U9,H1,P3,L1,K2,U9...in teh second row, the first is the name of the customer. I need to sum these five code by quantity (the quanity is in the third row).
– Diegoctn
Nov 8 at 14:05
Still i would say that give a screenshot or a sample of your sheet, if your data is sensitive you can create some random figures, like customer 1 customer 2.. What i have understood with your comment may not be the actual case so it is better to be confirmed, and also let me know what would happen with these headers after a column is inserted and why it is inserted. and another thing is if you want to address someone in comments you have to write his name with @ like @Diegoctn
– usmanhaq
Nov 9 at 2:29
add a comment |
If they only add one column?
– Darren Bartrup-Cook
Nov 8 at 11:35
Are the columns in between empty? And are the values text or numeric or mixture? And does it always start at column A?
– QHarr
Nov 8 at 11:42
As per your comments, their doestn't seems to be any defined logic that can be used to have the sum, (neither even/odd nor the sum()) but maybe the sum can be linked with the headers, it would be helpful if you can take a screenshot of your sheet and paste it here.
– usmanhaq
Nov 8 at 11:51
Hi usmanhaq, you are correct. All the columns follow the same logic H1,P3,L1,K2,U9 these are codes repeated for each customer so the sheet looks like: H1,P3,L1,K2,U9,H1,P3,L1,K2,U9,H1,P3,L1,K2,U9,H1,P3,L1,K2,U9...in teh second row, the first is the name of the customer. I need to sum these five code by quantity (the quanity is in the third row).
– Diegoctn
Nov 8 at 14:05
Still i would say that give a screenshot or a sample of your sheet, if your data is sensitive you can create some random figures, like customer 1 customer 2.. What i have understood with your comment may not be the actual case so it is better to be confirmed, and also let me know what would happen with these headers after a column is inserted and why it is inserted. and another thing is if you want to address someone in comments you have to write his name with @ like @Diegoctn
– usmanhaq
Nov 9 at 2:29
If they only add one column?
– Darren Bartrup-Cook
Nov 8 at 11:35
If they only add one column?
– Darren Bartrup-Cook
Nov 8 at 11:35
Are the columns in between empty? And are the values text or numeric or mixture? And does it always start at column A?
– QHarr
Nov 8 at 11:42
Are the columns in between empty? And are the values text or numeric or mixture? And does it always start at column A?
– QHarr
Nov 8 at 11:42
As per your comments, their doestn't seems to be any defined logic that can be used to have the sum, (neither even/odd nor the sum()) but maybe the sum can be linked with the headers, it would be helpful if you can take a screenshot of your sheet and paste it here.
– usmanhaq
Nov 8 at 11:51
As per your comments, their doestn't seems to be any defined logic that can be used to have the sum, (neither even/odd nor the sum()) but maybe the sum can be linked with the headers, it would be helpful if you can take a screenshot of your sheet and paste it here.
– usmanhaq
Nov 8 at 11:51
Hi usmanhaq, you are correct. All the columns follow the same logic H1,P3,L1,K2,U9 these are codes repeated for each customer so the sheet looks like: H1,P3,L1,K2,U9,H1,P3,L1,K2,U9,H1,P3,L1,K2,U9,H1,P3,L1,K2,U9...in teh second row, the first is the name of the customer. I need to sum these five code by quantity (the quanity is in the third row).
– Diegoctn
Nov 8 at 14:05
Hi usmanhaq, you are correct. All the columns follow the same logic H1,P3,L1,K2,U9 these are codes repeated for each customer so the sheet looks like: H1,P3,L1,K2,U9,H1,P3,L1,K2,U9,H1,P3,L1,K2,U9,H1,P3,L1,K2,U9...in teh second row, the first is the name of the customer. I need to sum these five code by quantity (the quanity is in the third row).
– Diegoctn
Nov 8 at 14:05
Still i would say that give a screenshot or a sample of your sheet, if your data is sensitive you can create some random figures, like customer 1 customer 2.. What i have understood with your comment may not be the actual case so it is better to be confirmed, and also let me know what would happen with these headers after a column is inserted and why it is inserted. and another thing is if you want to address someone in comments you have to write his name with @ like @Diegoctn
– usmanhaq
Nov 9 at 2:29
Still i would say that give a screenshot or a sample of your sheet, if your data is sensitive you can create some random figures, like customer 1 customer 2.. What i have understood with your comment may not be the actual case so it is better to be confirmed, and also let me know what would happen with these headers after a column is inserted and why it is inserted. and another thing is if you want to address someone in comments you have to write his name with @ like @Diegoctn
– usmanhaq
Nov 9 at 2:29
add a comment |
2 Answers
2
active
oldest
votes
up vote
1
down vote
Replace:
=A1+C1
By:
=SUM(A1:C1) - B1
In case you want to check if the column number is divisble by three, you can use following formula:
=IF(MOD(COLUMN(A1);3)=0;A1;0) // I've put the values from 1 to 10 in A1-J1
// and I've dragged this formula from A2 to J2,
// the values were 0,0,3,0,0,6,0,0,9,0.
Unfortunately I don't have a simple way to sum those values in one easy formula.
Hi Dominique, thanks but my problem is a little bit more complex. I have a cell with A1+D1+G1+J1...until the end and B1+E1+H1+K1...until the end. Now, if a user insert a new set of column I should be able to pick up the change. The range is always +3 columns A1+(A1+3 columns) D1+ (D1+3 columns) G1+.....no idea how can I achieve that. Is there a formula that can help me?
– Diegoctn
Nov 8 at 11:18
@Diegoctn: I've adapted my answer accordingly.
– Dominique
Nov 8 at 12:24
I know I thank you. As per above comment, I tried to simplify the question.
– Diegoctn
Nov 8 at 14:06
add a comment |
up vote
0
down vote
If you always add two columns then A1+C1
will always be looking at odd number columns and B1+D1
will always be looking at even numbered columns.
{=SUM(IF(ISODD(COLUMN($A$1:$D$1)),$A$1:$D$1))}
and
{=SUM(IF(ISEVEN(COLUMN($A$1:$D$1)),$A$1:$D$1))}
As long as you insert columns between A:D
the ranges will extend to accommodate.
Edit:
Based on the comment that row 2 contains codes and row 3 contains the figures to add up for each code then this array formula will work:
{=SUM(IF($A$2:$J$2="H1",$A$3:$J$3))}
Edit2: and if I wake up you can even use the non-array and built in formula:=SUMIF($A$2:$J$2,"H1",$A$3:$J$3)
The H1
text can be changed to another code or to a cell reference containing the code to get the sum of values in row 3 for the specified code.
As an array formula it must be entered using Ctrl+Shift+Enter
.
1
Don't forget to mention you're working with array formulas: you don't put the{
and}
characters yourself, you just enter the formula (starting with=
and instead of pressing ENTER, you press CONTROL+SHIFT+ENTER.
– Dominique
Nov 8 at 12:27
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
Replace:
=A1+C1
By:
=SUM(A1:C1) - B1
In case you want to check if the column number is divisble by three, you can use following formula:
=IF(MOD(COLUMN(A1);3)=0;A1;0) // I've put the values from 1 to 10 in A1-J1
// and I've dragged this formula from A2 to J2,
// the values were 0,0,3,0,0,6,0,0,9,0.
Unfortunately I don't have a simple way to sum those values in one easy formula.
Hi Dominique, thanks but my problem is a little bit more complex. I have a cell with A1+D1+G1+J1...until the end and B1+E1+H1+K1...until the end. Now, if a user insert a new set of column I should be able to pick up the change. The range is always +3 columns A1+(A1+3 columns) D1+ (D1+3 columns) G1+.....no idea how can I achieve that. Is there a formula that can help me?
– Diegoctn
Nov 8 at 11:18
@Diegoctn: I've adapted my answer accordingly.
– Dominique
Nov 8 at 12:24
I know I thank you. As per above comment, I tried to simplify the question.
– Diegoctn
Nov 8 at 14:06
add a comment |
up vote
1
down vote
Replace:
=A1+C1
By:
=SUM(A1:C1) - B1
In case you want to check if the column number is divisble by three, you can use following formula:
=IF(MOD(COLUMN(A1);3)=0;A1;0) // I've put the values from 1 to 10 in A1-J1
// and I've dragged this formula from A2 to J2,
// the values were 0,0,3,0,0,6,0,0,9,0.
Unfortunately I don't have a simple way to sum those values in one easy formula.
Hi Dominique, thanks but my problem is a little bit more complex. I have a cell with A1+D1+G1+J1...until the end and B1+E1+H1+K1...until the end. Now, if a user insert a new set of column I should be able to pick up the change. The range is always +3 columns A1+(A1+3 columns) D1+ (D1+3 columns) G1+.....no idea how can I achieve that. Is there a formula that can help me?
– Diegoctn
Nov 8 at 11:18
@Diegoctn: I've adapted my answer accordingly.
– Dominique
Nov 8 at 12:24
I know I thank you. As per above comment, I tried to simplify the question.
– Diegoctn
Nov 8 at 14:06
add a comment |
up vote
1
down vote
up vote
1
down vote
Replace:
=A1+C1
By:
=SUM(A1:C1) - B1
In case you want to check if the column number is divisble by three, you can use following formula:
=IF(MOD(COLUMN(A1);3)=0;A1;0) // I've put the values from 1 to 10 in A1-J1
// and I've dragged this formula from A2 to J2,
// the values were 0,0,3,0,0,6,0,0,9,0.
Unfortunately I don't have a simple way to sum those values in one easy formula.
Replace:
=A1+C1
By:
=SUM(A1:C1) - B1
In case you want to check if the column number is divisble by three, you can use following formula:
=IF(MOD(COLUMN(A1);3)=0;A1;0) // I've put the values from 1 to 10 in A1-J1
// and I've dragged this formula from A2 to J2,
// the values were 0,0,3,0,0,6,0,0,9,0.
Unfortunately I don't have a simple way to sum those values in one easy formula.
edited Nov 8 at 12:24
answered Nov 8 at 11:13
Dominique
1,26541437
1,26541437
Hi Dominique, thanks but my problem is a little bit more complex. I have a cell with A1+D1+G1+J1...until the end and B1+E1+H1+K1...until the end. Now, if a user insert a new set of column I should be able to pick up the change. The range is always +3 columns A1+(A1+3 columns) D1+ (D1+3 columns) G1+.....no idea how can I achieve that. Is there a formula that can help me?
– Diegoctn
Nov 8 at 11:18
@Diegoctn: I've adapted my answer accordingly.
– Dominique
Nov 8 at 12:24
I know I thank you. As per above comment, I tried to simplify the question.
– Diegoctn
Nov 8 at 14:06
add a comment |
Hi Dominique, thanks but my problem is a little bit more complex. I have a cell with A1+D1+G1+J1...until the end and B1+E1+H1+K1...until the end. Now, if a user insert a new set of column I should be able to pick up the change. The range is always +3 columns A1+(A1+3 columns) D1+ (D1+3 columns) G1+.....no idea how can I achieve that. Is there a formula that can help me?
– Diegoctn
Nov 8 at 11:18
@Diegoctn: I've adapted my answer accordingly.
– Dominique
Nov 8 at 12:24
I know I thank you. As per above comment, I tried to simplify the question.
– Diegoctn
Nov 8 at 14:06
Hi Dominique, thanks but my problem is a little bit more complex. I have a cell with A1+D1+G1+J1...until the end and B1+E1+H1+K1...until the end. Now, if a user insert a new set of column I should be able to pick up the change. The range is always +3 columns A1+(A1+3 columns) D1+ (D1+3 columns) G1+.....no idea how can I achieve that. Is there a formula that can help me?
– Diegoctn
Nov 8 at 11:18
Hi Dominique, thanks but my problem is a little bit more complex. I have a cell with A1+D1+G1+J1...until the end and B1+E1+H1+K1...until the end. Now, if a user insert a new set of column I should be able to pick up the change. The range is always +3 columns A1+(A1+3 columns) D1+ (D1+3 columns) G1+.....no idea how can I achieve that. Is there a formula that can help me?
– Diegoctn
Nov 8 at 11:18
@Diegoctn: I've adapted my answer accordingly.
– Dominique
Nov 8 at 12:24
@Diegoctn: I've adapted my answer accordingly.
– Dominique
Nov 8 at 12:24
I know I thank you. As per above comment, I tried to simplify the question.
– Diegoctn
Nov 8 at 14:06
I know I thank you. As per above comment, I tried to simplify the question.
– Diegoctn
Nov 8 at 14:06
add a comment |
up vote
0
down vote
If you always add two columns then A1+C1
will always be looking at odd number columns and B1+D1
will always be looking at even numbered columns.
{=SUM(IF(ISODD(COLUMN($A$1:$D$1)),$A$1:$D$1))}
and
{=SUM(IF(ISEVEN(COLUMN($A$1:$D$1)),$A$1:$D$1))}
As long as you insert columns between A:D
the ranges will extend to accommodate.
Edit:
Based on the comment that row 2 contains codes and row 3 contains the figures to add up for each code then this array formula will work:
{=SUM(IF($A$2:$J$2="H1",$A$3:$J$3))}
Edit2: and if I wake up you can even use the non-array and built in formula:=SUMIF($A$2:$J$2,"H1",$A$3:$J$3)
The H1
text can be changed to another code or to a cell reference containing the code to get the sum of values in row 3 for the specified code.
As an array formula it must be entered using Ctrl+Shift+Enter
.
1
Don't forget to mention you're working with array formulas: you don't put the{
and}
characters yourself, you just enter the formula (starting with=
and instead of pressing ENTER, you press CONTROL+SHIFT+ENTER.
– Dominique
Nov 8 at 12:27
add a comment |
up vote
0
down vote
If you always add two columns then A1+C1
will always be looking at odd number columns and B1+D1
will always be looking at even numbered columns.
{=SUM(IF(ISODD(COLUMN($A$1:$D$1)),$A$1:$D$1))}
and
{=SUM(IF(ISEVEN(COLUMN($A$1:$D$1)),$A$1:$D$1))}
As long as you insert columns between A:D
the ranges will extend to accommodate.
Edit:
Based on the comment that row 2 contains codes and row 3 contains the figures to add up for each code then this array formula will work:
{=SUM(IF($A$2:$J$2="H1",$A$3:$J$3))}
Edit2: and if I wake up you can even use the non-array and built in formula:=SUMIF($A$2:$J$2,"H1",$A$3:$J$3)
The H1
text can be changed to another code or to a cell reference containing the code to get the sum of values in row 3 for the specified code.
As an array formula it must be entered using Ctrl+Shift+Enter
.
1
Don't forget to mention you're working with array formulas: you don't put the{
and}
characters yourself, you just enter the formula (starting with=
and instead of pressing ENTER, you press CONTROL+SHIFT+ENTER.
– Dominique
Nov 8 at 12:27
add a comment |
up vote
0
down vote
up vote
0
down vote
If you always add two columns then A1+C1
will always be looking at odd number columns and B1+D1
will always be looking at even numbered columns.
{=SUM(IF(ISODD(COLUMN($A$1:$D$1)),$A$1:$D$1))}
and
{=SUM(IF(ISEVEN(COLUMN($A$1:$D$1)),$A$1:$D$1))}
As long as you insert columns between A:D
the ranges will extend to accommodate.
Edit:
Based on the comment that row 2 contains codes and row 3 contains the figures to add up for each code then this array formula will work:
{=SUM(IF($A$2:$J$2="H1",$A$3:$J$3))}
Edit2: and if I wake up you can even use the non-array and built in formula:=SUMIF($A$2:$J$2,"H1",$A$3:$J$3)
The H1
text can be changed to another code or to a cell reference containing the code to get the sum of values in row 3 for the specified code.
As an array formula it must be entered using Ctrl+Shift+Enter
.
If you always add two columns then A1+C1
will always be looking at odd number columns and B1+D1
will always be looking at even numbered columns.
{=SUM(IF(ISODD(COLUMN($A$1:$D$1)),$A$1:$D$1))}
and
{=SUM(IF(ISEVEN(COLUMN($A$1:$D$1)),$A$1:$D$1))}
As long as you insert columns between A:D
the ranges will extend to accommodate.
Edit:
Based on the comment that row 2 contains codes and row 3 contains the figures to add up for each code then this array formula will work:
{=SUM(IF($A$2:$J$2="H1",$A$3:$J$3))}
Edit2: and if I wake up you can even use the non-array and built in formula:=SUMIF($A$2:$J$2,"H1",$A$3:$J$3)
The H1
text can be changed to another code or to a cell reference containing the code to get the sum of values in row 3 for the specified code.
As an array formula it must be entered using Ctrl+Shift+Enter
.
edited Nov 8 at 14:21
answered Nov 8 at 11:43


Darren Bartrup-Cook
13k11431
13k11431
1
Don't forget to mention you're working with array formulas: you don't put the{
and}
characters yourself, you just enter the formula (starting with=
and instead of pressing ENTER, you press CONTROL+SHIFT+ENTER.
– Dominique
Nov 8 at 12:27
add a comment |
1
Don't forget to mention you're working with array formulas: you don't put the{
and}
characters yourself, you just enter the formula (starting with=
and instead of pressing ENTER, you press CONTROL+SHIFT+ENTER.
– Dominique
Nov 8 at 12:27
1
1
Don't forget to mention you're working with array formulas: you don't put the
{
and }
characters yourself, you just enter the formula (starting with =
and instead of pressing ENTER, you press CONTROL+SHIFT+ENTER.– Dominique
Nov 8 at 12:27
Don't forget to mention you're working with array formulas: you don't put the
{
and }
characters yourself, you just enter the formula (starting with =
and instead of pressing ENTER, you press CONTROL+SHIFT+ENTER.– Dominique
Nov 8 at 12:27
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53206011%2fsum-column-dynamically%23new-answer', 'question_page');
}
);
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
ppTxF7AzcdZv,It8K8BerNmBClgMBRO dreXlgdRAcA
If they only add one column?
– Darren Bartrup-Cook
Nov 8 at 11:35
Are the columns in between empty? And are the values text or numeric or mixture? And does it always start at column A?
– QHarr
Nov 8 at 11:42
As per your comments, their doestn't seems to be any defined logic that can be used to have the sum, (neither even/odd nor the sum()) but maybe the sum can be linked with the headers, it would be helpful if you can take a screenshot of your sheet and paste it here.
– usmanhaq
Nov 8 at 11:51
Hi usmanhaq, you are correct. All the columns follow the same logic H1,P3,L1,K2,U9 these are codes repeated for each customer so the sheet looks like: H1,P3,L1,K2,U9,H1,P3,L1,K2,U9,H1,P3,L1,K2,U9,H1,P3,L1,K2,U9...in teh second row, the first is the name of the customer. I need to sum these five code by quantity (the quanity is in the third row).
– Diegoctn
Nov 8 at 14:05
Still i would say that give a screenshot or a sample of your sheet, if your data is sensitive you can create some random figures, like customer 1 customer 2.. What i have understood with your comment may not be the actual case so it is better to be confirmed, and also let me know what would happen with these headers after a column is inserted and why it is inserted. and another thing is if you want to address someone in comments you have to write his name with @ like @Diegoctn
– usmanhaq
Nov 9 at 2:29