How to sum values in a cell based on information in a drop-down menu.

%3CLINGO-SUB%20id%3D%22lingo-sub-1660680%22%20slang%3D%22en-US%22%3EHow%20to%20sum%20values%20in%20a%20cell%20based%20on%20information%20in%20a%20drop-down%20menu.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1660680%22%20slang%3D%22en-US%22%3EHi%20All%2C%3CBR%20%2F%3E%3CBR%20%2F%3EI%20am%20just%20wondering%20if%20any%20Excel%20savvy%20people%20could%20tell%20me%20what%20formula%20I%20should%20use%20in%20order%20to%20sum%20the%20values%20of%20a%20cell%20in%20a%20different%20sheet%20based%20on%20information%20from%20a%20drop%20down%20menu.%20Basically%20I%20would%20like%20to%20be%20able%2C%20for%20my%20job%20have%20a%20Month%20to%20date%20figure%20based%20on%20the%20accumulated%20values%20from%20each%20week%2C%20and%20have%20them%20change%20based%20on%20the%20I%20information%20in%20my%20drop%20down%20menu.%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1660680%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EOffice%20365%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1660968%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20sum%20values%20in%20a%20cell%20based%20on%20information%20in%20a%20drop-down%20menu.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1660968%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F791406%22%20target%3D%22_blank%22%3E%40Aaiken353%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThat's%20bit%20abstract.%20Do%20you%20have%20hundreds%20of%20sheets%20and%20their%20number%20is%20variable%2C%20or%20few%20fixed%20number%20of%20sheets.%20What%20is%20the%20logic%20which%20links%20returned%20from%20drop-down%20value%20and%20values%20to%20sum%20-%20by%20position%2C%20by%20ID%2C%20by%20some%20calculations%2C%20etc.%20Is%20it%20one%20number%20from%20each%20sheet%20to%20sum%20or%20ranges%20which%20are%20to%20be%20summed.%20Perhaps%20more%20questions%2C%20but%20better%20to%20have%20small%20sample%20file%20which%20illustrates%20the%20task.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1737136%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20sum%20values%20in%20a%20cell%20based%20on%20information%20in%20a%20drop-down%20menu.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1737136%22%20slang%3D%22en-US%22%3EHi%20Sergei%2C%3CBR%20%2F%3EThanks%20for%20getting%20back%20to%20me.%20I've%20attached%20a%20file.%20Basically%20I%20want%20to%20know%2C%20using%20the%20file%20as%20an%20example%2C%20in%20sheet2%20I%20have%20weeks%20with%20a%20TY%20collum%20and%20a%20LY%20collum%2C%20TY%20figures%20are%20entered%20weekly%2C%20but%20LY%20figures%20are%20all%20inputted%2C%20my%20issue%20arises%20when%20we%20move%20to%20sheet1%20which%20has%20months%2C%20and%20a%20TY%20and%20LY%20collum%20and%20a%20cell%202%20has%20my%20drop%20down%20list%20with%20weeks%20in%20it.%20Basically%2C%20I%20now%20want%20my%20LY%20collum%20to%20only%20sum%20up%20the%20figures%20based%20on%20which%20week%20I'm%20in.%20So%20in%20march%20when%20I%20select%20week%205%2C%20LY%20collum%20should%20be%20the%20sum%20of%20week%201%20to%20week%204%20and%20April%20LY%20should%20be%20the%20sum%20of%20only%20week%205.%20And%20then%20when%20I%20select%20week%206%20from%20my%20drop%20down%20list%2C%20March%20LY%20remains%20the%20same%20but%20April%20LY%20is%20now%20the%20sum%20of%20week%205%20and%206%20from%20sheet%202%20LY%20collum.%20I%20hope%20this%20makes%20sense.%3C%2FLINGO-BODY%3E
New Contributor
Hi All,

I am just wondering if any Excel savvy people could tell me what formula I should use in order to sum the values of a cell in a different sheet based on information from a drop down menu. Basically I would like to be able, for my job have a Month to date figure based on the accumulated values from each week, and have them change based on the I information in my drop down menu.
5 Replies

@Aaiken353 

That's bit abstract. Do you have hundreds of sheets and their number is variable, or few fixed number of sheets. What is the logic which links returned from drop-down value and values to sum - by position, by ID, by some calculations, etc. Is it one number from each sheet to sum or ranges which are to be summed. Perhaps more questions, but better to have small sample file which illustrates the task.

Hi Sergei,
Thanks for getting back to me. I've attached a file. Basically I want to know, using the file as an example, in sheet2 I have weeks with a TY collum and a LY collum, TY figures are entered weekly, but LY figures are all inputted, my issue arises when we move to sheet1 which has months, and a TY and LY collum and a cell 2 has my drop down list with weeks in it. Basically, I now want my LY collum to only sum up the figures based on which week I'm in. So in march when I select week 5, LY collum should be the sum of week 1 to week 4 and April LY should be the sum of only week 5. And then when I select week 6 from my drop down list, March LY remains the same but April LY is now the sum of week 5 and 6 from sheet 2 LY collum. I hope this makes sense.

@Aaiken353 

Thank you for the file. Main question here is how Excel knows which week belongs to which number. Assume your Week #1 is from March - from first of march even if it is Sunday, or from first Monday of March or something else. Next, let assume 3 days of Week #5 are in March, rest are in April. Is that March week or April week?

 

We may create helper table with such mapping, but it will be for the concrete year. Next year days could be shifted and Week #5 from March will go on April. Better to define formal logic, after that with help of WEEKNUMBER() calculate which week is in which month.

 

As soon as we know that we may calculate the summary for each month, depends on selected week is within the month or after / before it.

Hi Sergei,

Thanks for the response, I think I'm a little confused. Basically I know which weeks belong to which months. In my example week 1 to week 4 is March and week 5 to week 8 is April. They are set, days don't change them and they are not set on a calender month. They are a fiscal representation of a period.
I am just wondering it it is possible to get sheet 1 LY collum to sum the figures from Sheet 2 LY collum based on the option from a drop down menu. For example if we take it that this current week we are in is week 6. Which is the second week of April then I just want the LY collum in sheet 1 next to April only sum the figures for week 5 and 6 into the collum and in the LY column it for March it would have summed all of the figures from sheet 2 LY column week 1 to week 4 . And this would be based on the change in my drop down menu which would now have selected week 6 as that is the week that I am in. Then continuing with this example. Next week i will be in week 7, therefore I will select week 7 on my drop down list on sheet 1. And then in the April LY column the figures will sum all the figures from sheet 2 LY collum week 5 to week 7 and March will remain the unchanged. I hope that's a better explanation. I'm not sure if what I'm wanting to do is possible, I thought it would have something to do with a whatif or lookup formula.

@Aaiken353 

When it'll be more complex.

First, we need to transfer to Excel your knowledge that WEEK1, WEEK2, WEEK3, WEEK4 are belong to March, another ones to April, etc.

Second, we need normalize names of weeks. Somewhere they are like "Week1", somewhere "Week 1" which is not the same. Sorting and compare texts could give wrong results. For example, if we compare texts like Week2 and Week12, first will be greater (or later) than the second. 

 

Without formal logic of how to calculate weeks we may add helper range at any place of the workbook as

image.png

note, we use numbers for weeks, not texts. With that formula could be

=SUMPRODUCT(
   ($E$4:$E$11<=--SUBSTITUTE($A$2,"WEEK",""))*
   ($F$4:$F$11=$A4)*
   (--SUBSTITUTE(Sheet2!$A$3:$A$10,"WEEK ","")<= --SUBSTITUTE($A$2,"WEEK",""))*
   Sheet2!$C$3:$C$10
)