# FORMULA HELP! (SUM between two cells)



## larinda4 (Dec 16, 2022)

I've been racking my brain trying to figure out a formula for this. I've included borders to help illustrate what I need.

I'm trying to sum column P based on the month in Q and subtract it from the debited amount in column S to get my monthly total in column T. I tried doing a SUMIF but as you'll see from the screenshot below, it won't calculate because there's a month for October and not November on the left and on the right, there's November and no October. Columns O and R are helper columns I created, but clearly it isn't working. 

Generally there are more blank rows on the left hand side, but I figured this would make it easier. The start of the month on the left hand side will always be the same row on the right hand side. . 

How can I sum this based on the month but also taking into account if the prior month is missing and adding it to the calculation?


----------



## DanteAmor (Dec 16, 2022)

larinda4 said:


> I'm trying to sum column P* based on the month in Q *and subtract it from the debited amount in column S


If you already have* the date in column Q*, check the following proposal. I am taking column R as a helper column to fill in the dates from column Q.
In column T are the totals using column R as a reference to calculate.

*NOTE XL2BB:*
For the future, it would help greatly if you could give us the sample data in a form that we can copy to test with, rather that a picture.
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.

*Example*:
Dante AmorPQRST1CreditedMonthDateDebitedMonthly Total234315/nov/202115/nov/2021(147)515/nov/2021150 6415/dic/202115/dic/2021200(84)711215/dic/2021 8515/ene/202215/ene/2022215126915015/ene/2022 1018615/ene/2022 111015/feb/202215/feb/2022300(284)12615/feb/2022 13715/mar/202215/mar/202247590141015/mar/2022 1554815/mar/2022 16415/abr/202215/abr/202242596171515/abr/2022 1850215/abr/2022 1915/may/202215/may/2022600(59)201415/may/2022 2152715/may/2022 224215/jun/202215/jun/2022650(570)233815/jun/2022 2477815/jul/202215/jul/2022425385253215/jul/2022 26515/ago/202215/ago/2022926352790415/ago/2022 285215/ago/2022 2947215/sep/202215/sep/2022664(170)302215/sep/2022 3115/sep/2022 32715/oct/202215/oct/2022247(171)336915/oct/2022 Hoja8Cell FormulasRangeFormulaR4:R33R4=IF(Q4<>"",Q4,R3)T4:T33T4=IF(Q4<>"",SUMIF(R:R,Q4,P:P)-SUMIF(R:R,Q4,S:S),"")


----------

