Question

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.

Was it helpful?

Solution 3

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

OTHER TIPS

INDIRECT() is your friend...

assuming you have your table at the top of the sheet and that A4 contains the month you want to stop...

=SUM(INDIRECT("B2:"&A4&"2"))

if you want to add a dynamic twist to the formula, name your cells as MONTHVALUES, then you can get its address with ROW(monthvalues) and COLUMN(monthvalues)

and the current month column would become COLUMN(monthvalues)+MONTH(NOW())-1

and if you name a cell containing the desiredrow

so you can refer back to the range from january to column month of the desired row as

=SUM(INDIRECT(ADDRESS(ROW(monthvalues)+desiredrow-1;COLUMN(monthvalues))&":"&ADDRESS(ROW(monthvalues)+desiredrow-1;COLUMN(monthvalues)+MONTH(NOW()))))

Another way is to use INDEX and MATCH.

=SUM(B2:INDEX(B2:M2,1,MATCH(UPPER(TEXT(TODAY(),"MMM")),B1:M1,FALSE)))

See http://datapigtechnologies.com/blog/index.php/using-indexmatch-as-a-cell-reference/ for more information.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top