|
|
Question : Trying to Sum of Rows Specified within a Date Range (by Year)
|
|
|
|
I am trying to sum a row of numbers that are categorized under a certain range. My data looks something like:
12/3/09 1/14/10 7/21/10 12/8/10 2/14/11 Category A $ 1.00 $ 8.00 $ 7.00 $ 8.00 $ 1.00 Category B $11.00 $ 2.00 $ 4.00 $15.00 $11.00 Category C $ 7.00 $ 3.00 $ 7.00 $ 5.00 $ 8.00 Category D $ 1.00 $ 8.00 $ 3.00 $ 4.00 $ 7.00 Category E $ 3.00 $ 9.00 $ 2.00 $ 3.00 $ 5.00 Category F $ 4.00 $ 8.00 $12.00 $ 1.00 $10.00
Also, the user enters a date into another cell, such as "4/12/10".
Challenge: I want to write a formula that would sum all amounts within that year based on the date entered. Specifically, if the user enters 4/12/10, then the formula would sum all amounts in the columns (in this example, the 2nd, 3rd, and 4th) that are within 2010 (1/1/10 to 12/31/10). If the user enters 8/18/09, it would add all amounts in the columns that are in 2009 (1/1/09 to 12/31/2009).
Can anyone help with the formula? I have tried HLOOKUP and SUMIF but I am stuck on how to take a date like 4/12/10 and restrict it to the year (2010).
Thanks for your help (ps sorry I just saw this was posted in the MS Access zone and I cannot delete it)
|
|
|
|
Answer : Trying to Sum of Rows Specified within a Date Range (by Year)
|
|
|
|
Assuming that your table is in cells A1:F8, with that date in cell i1, you can use the following formula in cell G2 =SUMPRODUCT((YEAR($B$1:$F$1)=YEAR($I$1))*B2:F2)
See attached file.
Thomas
|
|
|
|
|