ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   sum automatically from last 12 months based on current date (https://www.excelbanter.com/excel-worksheet-functions/8474-sum-automatically-last-12-months-based-current-date.html)

CDSchomaker

sum automatically from last 12 months based on current date
 
I have a database consisting of monthly hours covering the last 10 years.
Occassionally, I need to sum up the hours from the last 12 months. Which
Excel function do I use so that a cell will automatically show the sum of
hours from the last 12 months based on the current date?

Don Guillett

assuming valid dates in col A, try

=SUMPRODUCT((A1:A40=EDATE(TODAY(),-12))*(A1:A40<=TODAY())*B1:B40)

--
Don Guillett
SalesAid Software

"CDSchomaker" wrote in message
...
I have a database consisting of monthly hours covering the last 10 years.
Occassionally, I need to sum up the hours from the last 12 months. Which
Excel function do I use so that a cell will automatically show the sum of
hours from the last 12 months based on the current date?




Frank Kabel

Hi
and just an alternative to Don' solution which does not need the Analysis
Toolpak Addin:
=SUMPRODUCT(--(A1:A100=DATE(YEAR(TODAY())-1,MONTH(TODAY()),DAY(TODAY())),--(A1:A100<=TODAY()),B1:B100)

Also check:
http://www.xldynamic.com/source/xld.SUMPRODUCT.html

--
Regards
Frank Kabel
Frankfurt, Germany

CDSchomaker wrote:
I have a database consisting of monthly hours covering the last 10
years. Occassionally, I need to sum up the hours from the last 12
months. Which Excel function do I use so that a cell will
automatically show the sum of hours from the last 12 months based on
the current date?





All times are GMT +1. The time now is 03:25 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com