A dynamic sum formula - Excel












1















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!










share|improve this question




















  • 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















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!










share|improve this question




















  • 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








1








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!










share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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














  • 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












1 Answer
1






active

oldest

votes


















2














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 to F$3:$L$3 (F being the sixth column - replace 6 with the MATCH function).


  • SUM(F$3:$L$3) adds it all up. Replace F$3:$L$3 with the INDEX.


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)))





share|improve this answer





















  • 1





    Much Apprecaited!

    – Nasser Abdulrahman
    Jan 2 at 16:08











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
});


}
});














draft saved

draft discarded


















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









2














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 to F$3:$L$3 (F being the sixth column - replace 6 with the MATCH function).


  • SUM(F$3:$L$3) adds it all up. Replace F$3:$L$3 with the INDEX.


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)))





share|improve this answer





















  • 1





    Much Apprecaited!

    – Nasser Abdulrahman
    Jan 2 at 16:08
















2














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 to F$3:$L$3 (F being the sixth column - replace 6 with the MATCH function).


  • SUM(F$3:$L$3) adds it all up. Replace F$3:$L$3 with the INDEX.


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)))





share|improve this answer





















  • 1





    Much Apprecaited!

    – Nasser Abdulrahman
    Jan 2 at 16:08














2












2








2







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 to F$3:$L$3 (F being the sixth column - replace 6 with the MATCH function).


  • SUM(F$3:$L$3) adds it all up. Replace F$3:$L$3 with the INDEX.


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)))





share|improve this answer















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 to F$3:$L$3 (F being the sixth column - replace 6 with the MATCH function).


  • SUM(F$3:$L$3) adds it all up. Replace F$3:$L$3 with the INDEX.


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)))






share|improve this answer














share|improve this answer



share|improve this answer








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














  • 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




















draft saved

draft discarded




















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Monofisismo

Angular Downloading a file using contenturl with Basic Authentication

Olmecas