Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sum number of cells based on current date in excel spreadsheet

I've got a spreadsheet like this:

date | 7/1 | 7/2 | 7/3 | 7/4
-----|-----|-----|-----|-----
 val |  3  |  5  |  1  |  3  
-----|-----|-----|-----|-----

I want to sum the val row, but only up to the current date. So if today were 7/3, the sum would be 3+5+1=9. If today were 7/4, it would be 12.

I figured this out to get the number of columns:

=YEARFRAC(B1,TODAY())*360  // B1 is the first date -- 7/1

but I can't figure out how to tell excel to do the sum:

=SUM(B2:<B+num cols above>2)

Presumably its something to do with references, and lookup, but I'm not really familiar with how those work....

like image 467
sprugman Avatar asked Jul 08 '09 22:07

sprugman


People also ask

How do you count cells based on date?

COUNTIFS - Count in Date Range If you need to count the number of cells, based on one or more criteria, use the COUNTIFS function. In the example below, the formula will count the rows where the date (column A) is within our set date range.

How do I sum corresponding values with the same data in Excel?

For example, the formula =SUMIF(B2:B5, "John", C2:C5) sums only the values in the range C2:C5, where the corresponding cells in the range B2:B5 equal "John." To sum cells based on multiple criteria, see SUMIFS function.

How do you auto sum certain cells in Excel?

Select a cell next to the numbers you want to sum, click AutoSum on the Home tab, press Enter, and you're done. When you click AutoSum, Excel automatically enters a formula (that uses the SUM function) to sum the numbers.


1 Answers

You can use SUMIF:

=SUMIF(A1:E1,"<="&TODAY(),A2:E2)

Assuming your dates are in a1:e1 and your values are in a2:e2.

like image 181
edoloughlin Avatar answered Sep 27 '22 22:09

edoloughlin