Column B has part number: 100-00-001 for example. Column C has the month: Jan 2013, Feb 2013. D has quantity of demand forecasted.

We want to put all demand in August. If demand is:

1/28/2013 0
2/11/2013 0
3/11/2013 0
4/15/2013 0
5/13/2013 0
6/17/2013 0
7/15/2013 0
8/12/2013 0
9/16/2013 50
10/14/2013 0
11/11/2013 50
12/16/2013 0

We want it to become:

1/28/2013 0
2/11/2013 0
3/11/2013 0
4/15/2013 0
5/13/2013 0
6/17/2013 0
7/15/2013 0
8/12/2013 100
9/16/2013 0
10/14/2013 0
11/11/2013 0
12/16/2013 0

I have a formula in column G:

=IF(C2389=41498,SUM(D$2389:D$2400),0)

In other words, if the date is 8/12/2013, quantity is the sum of all months. Otherwise, sum is 0.

I want to repeat this formula 12 times (for 12 months) and then adjust it so it has the 12 month sum for the next part number:

=IF(C2401=41498,SUM(D$2401:D$2412),0)

and then:

=IF(C2413=41498,SUM(D$2413:D$2424),0)

et cetera

Is there a way to automatize this?

Do I write a macro? Use a better formula?