A dynamic sum formula - Excel
Guys I am trying to write a dynamic sum formula where the array range starts from a cut-off date ( this date changes every month ).
I have the periods in the top first row 201801 in A2
, 201802 in B2
etc.
and starting from A3
I have the sales' figures.
e.g. the cut-off date is 201806, so I need my sum formula to be =sum($F3:L3)
what I was trying to do is =sum(ADDRESS(3,MATCH($B$1,$A$2:$L$2,0),3):L3)
ADDRESS(3,MATCH($B$1,$A$2:$L$2,0),3)
returns $F3
which does not work in the sum formula!
excel
add a comment |
Guys I am trying to write a dynamic sum formula where the array range starts from a cut-off date ( this date changes every month ).
I have the periods in the top first row 201801 in A2
, 201802 in B2
etc.
and starting from A3
I have the sales' figures.
e.g. the cut-off date is 201806, so I need my sum formula to be =sum($F3:L3)
what I was trying to do is =sum(ADDRESS(3,MATCH($B$1,$A$2:$L$2,0),3):L3)
ADDRESS(3,MATCH($B$1,$A$2:$L$2,0),3)
returns $F3
which does not work in the sum formula!
excel
1
You just need and INDIRECT to convert to a range ref=SUM(INDIRECT(ADDRESS(3,MATCH($B$1,$A$2:$L$2,0),3) &":L3"))
.
– SJR
Jan 2 at 12:37
Thank you very much
– Nasser Abdulrahman
Jan 2 at 16:08
add a comment |
Guys I am trying to write a dynamic sum formula where the array range starts from a cut-off date ( this date changes every month ).
I have the periods in the top first row 201801 in A2
, 201802 in B2
etc.
and starting from A3
I have the sales' figures.
e.g. the cut-off date is 201806, so I need my sum formula to be =sum($F3:L3)
what I was trying to do is =sum(ADDRESS(3,MATCH($B$1,$A$2:$L$2,0),3):L3)
ADDRESS(3,MATCH($B$1,$A$2:$L$2,0),3)
returns $F3
which does not work in the sum formula!
excel
Guys I am trying to write a dynamic sum formula where the array range starts from a cut-off date ( this date changes every month ).
I have the periods in the top first row 201801 in A2
, 201802 in B2
etc.
and starting from A3
I have the sales' figures.
e.g. the cut-off date is 201806, so I need my sum formula to be =sum($F3:L3)
what I was trying to do is =sum(ADDRESS(3,MATCH($B$1,$A$2:$L$2,0),3):L3)
ADDRESS(3,MATCH($B$1,$A$2:$L$2,0),3)
returns $F3
which does not work in the sum formula!
excel
excel
edited Jan 2 at 14:02
Darren Bartrup-Cook
14k11433
14k11433
asked Jan 2 at 12:25
Nasser AbdulrahmanNasser Abdulrahman
82
82
1
You just need and INDIRECT to convert to a range ref=SUM(INDIRECT(ADDRESS(3,MATCH($B$1,$A$2:$L$2,0),3) &":L3"))
.
– SJR
Jan 2 at 12:37
Thank you very much
– Nasser Abdulrahman
Jan 2 at 16:08
add a comment |
1
You just need and INDIRECT to convert to a range ref=SUM(INDIRECT(ADDRESS(3,MATCH($B$1,$A$2:$L$2,0),3) &":L3"))
.
– SJR
Jan 2 at 12:37
Thank you very much
– Nasser Abdulrahman
Jan 2 at 16:08
1
1
You just need and INDIRECT to convert to a range ref
=SUM(INDIRECT(ADDRESS(3,MATCH($B$1,$A$2:$L$2,0),3) &":L3"))
.– SJR
Jan 2 at 12:37
You just need and INDIRECT to convert to a range ref
=SUM(INDIRECT(ADDRESS(3,MATCH($B$1,$A$2:$L$2,0),3) &":L3"))
.– SJR
Jan 2 at 12:37
Thank you very much
– Nasser Abdulrahman
Jan 2 at 16:08
Thank you very much
– Nasser Abdulrahman
Jan 2 at 16:08
add a comment |
1 Answer
1
active
oldest
votes
INDIRECT
is volatile so may not be the best function to use.
I take it that L3
is static, and you're looking to sum from the lookup value to L3
.
MATCH(201806,$2:$2,0)
will return the column number that 201806 first appears in.
INDEX($3:$3,,6):$L$3
will return a reference toF$3:$L$3
(F
being the sixth column - replace6
with theMATCH
function).
SUM(F$3:$L$3)
adds it all up. ReplaceF$3:$L$3
with theINDEX
.
The final formula would be:
=SUM(INDEX($3:$3,,MATCH(201806,$2:$2,0)):$L$3)
Replace 201806
with a range reference.
If the end date is variable you can use another INDEX
function to find it.
This finds the last date using the MAX
function:
=SUM(INDEX($3:$3,,MATCH(201806,$2:$2,0)):INDEX($3:$3,,MATCH(MAX($2:$2),$2:$2,0)))
This adds from June to December:
=SUM(INDEX($3:$3,,MATCH(201806,$2:$2,0)):INDEX($3:$3,,MATCH(201812,$2:$2,0)))
1
Much Apprecaited!
– Nasser Abdulrahman
Jan 2 at 16:08
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
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
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54006370%2fa-dynamic-sum-formula-excel%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
INDIRECT
is volatile so may not be the best function to use.
I take it that L3
is static, and you're looking to sum from the lookup value to L3
.
MATCH(201806,$2:$2,0)
will return the column number that 201806 first appears in.
INDEX($3:$3,,6):$L$3
will return a reference toF$3:$L$3
(F
being the sixth column - replace6
with theMATCH
function).
SUM(F$3:$L$3)
adds it all up. ReplaceF$3:$L$3
with theINDEX
.
The final formula would be:
=SUM(INDEX($3:$3,,MATCH(201806,$2:$2,0)):$L$3)
Replace 201806
with a range reference.
If the end date is variable you can use another INDEX
function to find it.
This finds the last date using the MAX
function:
=SUM(INDEX($3:$3,,MATCH(201806,$2:$2,0)):INDEX($3:$3,,MATCH(MAX($2:$2),$2:$2,0)))
This adds from June to December:
=SUM(INDEX($3:$3,,MATCH(201806,$2:$2,0)):INDEX($3:$3,,MATCH(201812,$2:$2,0)))
1
Much Apprecaited!
– Nasser Abdulrahman
Jan 2 at 16:08
add a comment |
INDIRECT
is volatile so may not be the best function to use.
I take it that L3
is static, and you're looking to sum from the lookup value to L3
.
MATCH(201806,$2:$2,0)
will return the column number that 201806 first appears in.
INDEX($3:$3,,6):$L$3
will return a reference toF$3:$L$3
(F
being the sixth column - replace6
with theMATCH
function).
SUM(F$3:$L$3)
adds it all up. ReplaceF$3:$L$3
with theINDEX
.
The final formula would be:
=SUM(INDEX($3:$3,,MATCH(201806,$2:$2,0)):$L$3)
Replace 201806
with a range reference.
If the end date is variable you can use another INDEX
function to find it.
This finds the last date using the MAX
function:
=SUM(INDEX($3:$3,,MATCH(201806,$2:$2,0)):INDEX($3:$3,,MATCH(MAX($2:$2),$2:$2,0)))
This adds from June to December:
=SUM(INDEX($3:$3,,MATCH(201806,$2:$2,0)):INDEX($3:$3,,MATCH(201812,$2:$2,0)))
1
Much Apprecaited!
– Nasser Abdulrahman
Jan 2 at 16:08
add a comment |
INDIRECT
is volatile so may not be the best function to use.
I take it that L3
is static, and you're looking to sum from the lookup value to L3
.
MATCH(201806,$2:$2,0)
will return the column number that 201806 first appears in.
INDEX($3:$3,,6):$L$3
will return a reference toF$3:$L$3
(F
being the sixth column - replace6
with theMATCH
function).
SUM(F$3:$L$3)
adds it all up. ReplaceF$3:$L$3
with theINDEX
.
The final formula would be:
=SUM(INDEX($3:$3,,MATCH(201806,$2:$2,0)):$L$3)
Replace 201806
with a range reference.
If the end date is variable you can use another INDEX
function to find it.
This finds the last date using the MAX
function:
=SUM(INDEX($3:$3,,MATCH(201806,$2:$2,0)):INDEX($3:$3,,MATCH(MAX($2:$2),$2:$2,0)))
This adds from June to December:
=SUM(INDEX($3:$3,,MATCH(201806,$2:$2,0)):INDEX($3:$3,,MATCH(201812,$2:$2,0)))
INDIRECT
is volatile so may not be the best function to use.
I take it that L3
is static, and you're looking to sum from the lookup value to L3
.
MATCH(201806,$2:$2,0)
will return the column number that 201806 first appears in.
INDEX($3:$3,,6):$L$3
will return a reference toF$3:$L$3
(F
being the sixth column - replace6
with theMATCH
function).
SUM(F$3:$L$3)
adds it all up. ReplaceF$3:$L$3
with theINDEX
.
The final formula would be:
=SUM(INDEX($3:$3,,MATCH(201806,$2:$2,0)):$L$3)
Replace 201806
with a range reference.
If the end date is variable you can use another INDEX
function to find it.
This finds the last date using the MAX
function:
=SUM(INDEX($3:$3,,MATCH(201806,$2:$2,0)):INDEX($3:$3,,MATCH(MAX($2:$2),$2:$2,0)))
This adds from June to December:
=SUM(INDEX($3:$3,,MATCH(201806,$2:$2,0)):INDEX($3:$3,,MATCH(201812,$2:$2,0)))
edited Jan 2 at 14:00
answered Jan 2 at 13:54
Darren Bartrup-CookDarren Bartrup-Cook
14k11433
14k11433
1
Much Apprecaited!
– Nasser Abdulrahman
Jan 2 at 16:08
add a comment |
1
Much Apprecaited!
– Nasser Abdulrahman
Jan 2 at 16:08
1
1
Much Apprecaited!
– Nasser Abdulrahman
Jan 2 at 16:08
Much Apprecaited!
– Nasser Abdulrahman
Jan 2 at 16:08
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54006370%2fa-dynamic-sum-formula-excel%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
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
Required, but never shown
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
Required, but never shown
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
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
You just need and INDIRECT to convert to a range ref
=SUM(INDIRECT(ADDRESS(3,MATCH($B$1,$A$2:$L$2,0),3) &":L3"))
.– SJR
Jan 2 at 12:37
Thank you very much
– Nasser Abdulrahman
Jan 2 at 16:08