Sumproduct to sum date range

erniepoe

Active Member
Joined
Oct 23, 2006
Messages
375
Office Version
  1. 365
Platform
  1. Windows
Hi all,

Have a formula that is giving me a #spill error, likely because the formula is in row 87. Row 2 is months from 2023-2029, and i want to sum all the values in row 87 if the constraints hold, i.e. sum all the values for that year up to the current month. So sum jan-may if in june, jan-july if in august, etc.

Anyone know how i can rewrite this formula to be in row 87 without error? Thank you so much.

Cheers,
Ernie

=SUMPRODUCT(--(YEAR($S$2:$CX$2)=YEAR(V$2))*($S$2:$CX$2<V$2)*($S$87:$CX$87))
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Try:

Excel Formula:
=SUMPRODUCT(($S$2:$CX$2<DATE(YEAR(TODAY()),MONTH(TODAY()),1))*($S$87:$CX$87))
 
Upvote 0
Can you post some sample data.

MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are. Instructions on using this tool can be found here: XL2BB Add-in

Note that there is also a "Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.
 
Upvote 0
As was the case with your previous thread that Fluff also responded to, the formula works fine in principle and does not cause a #SPILL error when I try it.
I tried some different combinations and can not get it to generate a spill error.
If you want everything in the current year up the current month (ie YTD) using V2 doesn't seem to make sense. We would expect to see either Today() in the formula or a cell that contains your reporting date.
(Dante's formula does not restrict the selection to the current year, so if you want current YTD it won't work for you but may still be helpful in seeing if it overcomes your Spill scenario)

If you respond to Fluff's request for an XL2BB we can see if we can figure out what is going on.

20231031 Sum Date Range SumProduct erniepoe.xlsm
QRSTUVWXYZAAABACADAE
2Jan-23Feb-23Mar-23Apr-23May-23Jun-23Jul-23Aug-23Sep-23Oct-23Nov-23Dec-23Jan-24
86erniepoeerniepoe using Today()
87309010101010101010101010101010
Sheet1
Cell Formulas
RangeFormula
Q87Q87=SUMPRODUCT((YEAR($S$2:$CX$2)=YEAR(V$2))*($S$2:$CX$2<V$2)*($S$87:$CX$87))
R87R87=SUMPRODUCT((YEAR($S$2:$CX$2)=YEAR(TODAY()))*($S$2:$CX$2<EOMONTH(TODAY(),-1))*($S$87:$CX$87))
 
Upvote 0
The only way I can get a #spill error is if that error is in either of the two ranges used in the formula
 
Upvote 0

Forum statistics

Threads
1,215,124
Messages
6,123,190
Members
449,090
Latest member
bes000

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top