Search code examples
excelexcel-2007sumifs

Sum, Sumifs or Sumproduct, not sure which one to use?


I have the following table:

    JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC
A   10  20  30  40  50  60  70  80  90  100 110 120
B   20  40  60  80  100 120 140 160 180 200 220 240
C   30  60  90  120 150 180 210 240 270 300 330 360

I am trying to get the total sum of what A would be from the beginning of the year to the current month. Let's take this month for example, I want the sum of what A would be from January to September.


Solution

  • This formula will return sum of values in JAN thru the current month. I assumed table is at top of document and to the left.

    A values:

    =SUM(INDIRECT("B2:"&ADDRESS(2,MONTH(TODAY())+1,4)))
    

    B values:

    =SUM(INDIRECT("B3:"&ADDRESS(3,MONTH(TODAY())+1,4)))
    

    C values:

    =SUM(INDIRECT("B4:"&ADDRESS(4,MONTH(TODAY())+1,4)))
    

    *EDIT*

    To make it more dynamic, say you have in cell "H8" the value 'A' and want to return the A sum up to the current month, you can do it like this:

    =SUM(INDIRECT("B"&MATCH(H8,A1:A4,0)&":"&ADDRESS(MATCH(H8,A1:A4,0),MONTH(TODAY())+1,4)))