SUMIFS

Haree

Board Regular
Joined
Sep 22, 2019
Messages
146
Office Version
  1. 2016
Hello all my data is from column A to column H
I am using the below mentioned formula
=SUMIFS($C$2:$C$2002,$G$2:$G$2002,12,$B$2:$B$2002,"Sales",$H$2:$H$2002,IF((G:G<=3), $R$1+1, $R$1))
The if part IF((G:G<=3), $R$1+1, $R$1)) isn't working correctly
My actual requirement is column g has numbers from 1 to 12 and column H has years . I have a year referenced in R1 if column g's value is below or equal to 3 the corresponding H value should be R1+1 else it should be R1 this is the criteria

Any help would be greatly appreciated.
Thanks
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
What is in $R$1? Providing a sample of data would be extremely helpful. If possible please use the xl2bb add in (link below) to post a mini workbook. If you cannot use that then please post a column and row labeled table. What other values can be in Column B? What values and data types are in column H?

Please help the forum help you. Thanks in advance.
 
Upvote 0
Hello @awoohaw Thank you for your time and Patience . Attaching a sample of rough data with XL2bb

Gold Stock New.xlsm
ABCDEFGH
1DateParticularsNo of PiecesWeightCl.Bal (P)Cl.Bal (W)MonthYear
2######Opening Balance4361267.54361267.5122023
3######Sales14.154351263.35122023
4######Sales14.214341259.14122023
5######Sales11.544331257.6122023
6######Sales12.14321255.5122023
7######Sales14.384311251.1212024
8######Sales12.094301249.0312024
9######Sales12.03429124712024
10######Sales12.264281244.7412024
11######Sales12.994271241.7512024
12######Sales11.174261240.5812024
13######Sales14.154251236.4312024
14######Purchase14.144261240.5772024
15######Purchase1036.314361276.88102024
Kammal (Pair)
Cell Formulas
RangeFormula
E3:E15E3=IF(ISBLANK(A3),"",IF(B3="Sales",E2-C3,E2+C3))
F3:F15F3=IF(ISBLANK(A3),"",IF(B3="Sales",F2-D3,F2+D3))
G3:G15G3=IF(ISBLANK(A3),"",MONTH(A3))
H3:H15H3=IF(ISBLANK(A3),"",YEAR(A3))
Cells with Conditional Formatting
CellConditionCell FormatStop If True
B15Cell Valuecontains "Purchase"textNO
B15Cell Valuecontains "Sales"textNO
B14Cell Valuecontains "Purchase"textNO
B14Cell Valuecontains "Sales"textNO
B13Cell Valuecontains "Purchase"textNO
B13Cell Valuecontains "Sales"textNO
B12Cell Valuecontains "Purchase"textNO
B12Cell Valuecontains "Sales"textNO
B11Cell Valuecontains "Purchase"textNO
B11Cell Valuecontains "Sales"textNO
B10Cell Valuecontains "Purchase"textNO
B10Cell Valuecontains "Sales"textNO
B9Cell Valuecontains "Purchase"textNO
B9Cell Valuecontains "Sales"textNO
B8Cell Valuecontains "Purchase"textNO
B8Cell Valuecontains "Sales"textNO
B7Cell Valuecontains "Purchase"textNO
B7Cell Valuecontains "Sales"textNO
B6Cell Valuecontains "Purchase"textNO
B6Cell Valuecontains "Sales"textNO
B5Cell Valuecontains "Purchase"textNO
B5Cell Valuecontains "Sales"textNO
B4Cell Valuecontains "Purchase"textNO
B4Cell Valuecontains "Sales"textNO
B3Cell Valuecontains "Purchase"textNO
B3Cell Valuecontains "Sales"textNO
Cells with Data Validation
CellAllowCriteria
B3:B15ListPurchase,Sales

Gold Stock New.xlsm
OPQRSTUV
1Year Starting2023No MatchNo Match
2
3MonthPurchase PPurchase WSales PSales WClosing Bal PClosing Bal W
4April00004361267.5
5May00004361267.5
6June00004361267.5
7July 10004371267.5
8August00004371267.5
9September00004371267.5
10October100004471267.5
11November00004471267.5
12December004124431255.5
13January00004431255.5
14February00004431255.5
15March00004431255.5
Kammal (Pair)
Cell Formulas
RangeFormula
P4P4=SUMIFS($C$2:$C$2002,$G$2:$G$2002,4,$B$2:$B$2002,"Purchase",$H$2:$H$2002,IF(AND($G:$G>=1, $G:$G<=3), $R$1+1, $R$1))
Q4Q4=SUMIFS($D$2:$D$2002,$G$2:$G$2002,4,$B$2:$B$2002,"Purchase",$H$2:$H$2002,IF(AND($G:$G>=1, $G:$G<=3), $R$1+1, $R$1))
R4R4=SUMIFS($C$2:$C$2002,$G$2:$G$2002,4,$B$2:$B$2002,"Sales",$H$2:$H$2002,IF(AND($G:$G>=1, $G:$G<=3), $R$1+1, $R$1))
S4S4=SUMIFS($D$2:$D$2002,$G$2:$G$2002,4,$B$2:$B$2002,"Sales",$H$2:$H$2002,IF(AND($G:$G>=1, $G:$G<=3), $R$1+1, $R$1))
T4T4=IF(YEAR(A2)=R1,E2+P4-R4,S1+P4-R4)
U4U4=IF(YEAR(A2)=R1,F2+Q4-S4,T1+Q4-S4)
P5P5=SUMIFS($C$2:$C$2002,$G$2:$G$2002,5,$B$2:$B$2002,"Purchase",$H$2:$H$2002,IF(AND(G:G>=1, G:G<=3), $R$1+1, $R$1))
Q5Q5=SUMIFS($D$2:$D$2002,$G$2:$G$2002,5,$B$2:$B$2002,"Purchase",$H$2:$H$2002,IF(AND(H:H>=1, H:H<=3), $R$1+1, $R$1))
R5R5=SUMIFS($C$2:$C$2002,$G$2:$G$2002,5,$B$2:$B$2002,"Sales",$H$2:$H$2002,IF(AND(I:I>=1, I:I<=3), $R$1+1, $R$1))
S5S5=SUMIFS($D$2:$D$2002,$G$2:$G$2002,5,$B$2:$B$2002,"Sales",$H$2:$H$2002,IF(AND(J:J>=1, J:J<=3), $R$1+1, $R$1))
T5:U15T5=T4+P5-R5
P6P6=SUMIFS($C$2:$C$2002,$G$2:$G$2002,6,$B$2:$B$2002,"Purchase",$H$2:$H$2002,IF(AND(G:G>=1, G:G<=3), $R$1+1, $R$1))
Q6Q6=SUMIFS($D$2:$D$2002,$G$2:$G$2002,6,$B$2:$B$2002,"Purchase",$H$2:$H$2002,IF(AND(H:H>=1, H:H<=3), $R$1+1, $R$1))
R6R6=SUMIFS($C$2:$C$2002,$G$2:$G$2002,6,$B$2:$B$2002,"Sales",$H$2:$H$2002,IF(AND(I:I>=1, I:I<=3), $R$1+1, $R$1))
S6S6=SUMIFS($D$2:$D$2002,$G$2:$G$2002,6,$B$2:$B$2002,"Sales",$H$2:$H$2002,IF(AND(J:J>=1, J:J<=3), $R$1+1, $R$1))
P7P7=SUMIFS($C$2:$C$2002,$G$2:$G$2002,7,$B$2:$B$2002,"Purchase",$H$2:$H$2002,IF(AND(G:G>=1, G:G<=3), $R$1+1, $R$1))
Q7Q7=SUMIFS($D$2:$D$2002,$G$2:$G$2002,7,$B$2:$B$2002,"Purchase",$H$2:$H$2002,IF(AND(H:H>=1, H:H<=3), $R$1+1, $R$1))
R7R7=SUMIFS($C$2:$C$2002,$G$2:$G$2002,7,$B$2:$B$2002,"Sales",$H$2:$H$2002,IF(AND(I:I>=1, I:I<=3), $R$1+1, $R$1))
S7S7=SUMIFS($D$2:$D$2002,$G$2:$G$2002,7,$B$2:$B$2002,"Sales",$H$2:$H$2002,IF(AND(J:J>=1, J:J<=3), $R$1+1, $R$1))
P8P8=SUMIFS($C$2:$C$2002,$G$2:$G$2002,8,$B$2:$B$2002,"Purchase",$H$2:$H$2002,IF(AND(G:G>=1, G:G<=3), $R$1+1, $R$1))
Q8Q8=SUMIFS($D$2:$D$2002,$G$2:$G$2002,8,$B$2:$B$2002,"Purchase",$H$2:$H$2002,IF(AND(H:H>=1, H:H<=3), $R$1+1, $R$1))
R8R8=SUMIFS($C$2:$C$2002,$G$2:$G$2002,8,$B$2:$B$2002,"Sales",$H$2:$H$2002,IF(AND(I:I>=1, I:I<=3), $R$1+1, $R$1))
S8S8=SUMIFS($D$2:$D$2002,$G$2:$G$2002,8,$B$2:$B$2002,"Sales",$H$2:$H$2002,IF(AND(J:J>=1, J:J<=3), $R$1+1, $R$1))
P9P9=SUMIFS($C$2:$C$2002,$G$2:$G$2002,9,$B$2:$B$2002,"Purchase",$H$2:$H$2002,IF(AND(G:G>=1, G:G<=3), $R$1+1, $R$1))
Q9Q9=SUMIFS($D$2:$D$2002,$G$2:$G$2002,9,$B$2:$B$2002,"Purchase",$H$2:$H$2002,IF(AND(H:H>=1, H:H<=3), $R$1+1, $R$1))
R9R9=SUMIFS($C$2:$C$2002,$G$2:$G$2002,9,$B$2:$B$2002,"Sales",$H$2:$H$2002,IF(AND(I:I>=1, I:I<=3), $R$1+1, $R$1))
S9S9=SUMIFS($D$2:$D$2002,$G$2:$G$2002,9,$B$2:$B$2002,"Sales",$H$2:$H$2002,IF(AND(J:J>=1, J:J<=3), $R$1+1, $R$1))
P10P10=SUMIFS($C$2:$C$2002,$G$2:$G$2002,10,$B$2:$B$2002,"Purchase",$H$2:$H$2002,IF(AND(G:G>=1, G:G<=3), $R$1+1, $R$1))
Q10Q10=SUMIFS($D$2:$D$2002,$G$2:$G$2002,10,$B$2:$B$2002,"Purchase",$H$2:$H$2002,IF(AND(H:H>=1, H:H<=3), $R$1+1, $R$1))
R10R10=SUMIFS($C$2:$C$2002,$G$2:$G$2002,10,$B$2:$B$2002,"Sales",$H$2:$H$2002,IF(AND(I:I>=1, I:I<=3), $R$1+1, $R$1))
S10S10=SUMIFS($D$2:$D$2002,$G$2:$G$2002,10,$B$2:$B$2002,"Sales",$H$2:$H$2002,IF(AND(J:J>=1, J:J<=3), $R$1+1, $R$1))
P11P11=SUMIFS($C$2:$C$2002,$G$2:$G$2002,11,$B$2:$B$2002,"Purchase",$H$2:$H$2002,IF(AND(G:G>=1, G:G<=3), $R$1+1, $R$1))
Q11Q11=SUMIFS($D$2:$D$2002,$G$2:$G$2002,11,$B$2:$B$2002,"Purchase",$H$2:$H$2002,IF(AND(H:H>=1, H:H<=3), $R$1+1, $R$1))
R11R11=SUMIFS($C$2:$C$2002,$G$2:$G$2002,11,$B$2:$B$2002,"Sales",$H$2:$H$2002,IF(AND(I:I>=1, I:I<=3), $R$1+1, $R$1))
S11S11=SUMIFS($D$2:$D$2002,$G$2:$G$2002,11,$B$2:$B$2002,"Sales",$H$2:$H$2002,IF(AND(J:J>=1, J:J<=3), $R$1+1, $R$1))
P12P12=SUMIFS($C$2:$C$2002,$G$2:$G$2002,12,$B$2:$B$2002,"Purchase",$H$2:$H$2002,IF(AND(G:G>=1, G:G<=3), $R$1+1, $R$1))
Q12Q12=SUMIFS($D$2:$D$2002,$G$2:$G$2002,12,$B$2:$B$2002,"Purchase",$H$2:$H$2002,IF(AND(H:H>=1, H:H<=3), $R$1+1, $R$1))
R12R12=SUMIFS($C$2:$C$2002,$G$2:$G$2002,12,$B$2:$B$2002,"Sales",$H$2:$H$2002,IF(AND(I:I>=1, I:I<=3), $R$1+1, $R$1))
S12S12=SUMIFS($D$2:$D$2002,$G$2:$G$2002,12,$B$2:$B$2002,"Sales",$H$2:$H$2002,IF(AND(J:J>=1, J:J<=3), $R$1+1, $R$1))
P13P13=SUMIFS($C$2:$C$2002,$G$2:$G$2002,1,$B$2:$B$2002,"Purchase",$H$2:$H$2002,IF(AND(G:G>=1, G:G<=3), $R$1+1, $R$1))
Q13Q13=SUMIFS($D$2:$D$2002,$G$2:$G$2002,1,$B$2:$B$2002,"Purchase",$H$2:$H$2002,IF(AND(H:H>=1, H:H<=3), $R$1+1, $R$1))
R13R13=SUMIFS($C$2:$C$2002,$G$2:$G$2002,1,$B$2:$B$2002,"Sales",$H$2:$H$2002,IF(AND(I:I>=1, I:I<=3), $R$1+1, $R$1))
S13S13=SUMIFS($D$2:$D$2002,$G$2:$G$2002,1,$B$2:$B$2002,"Sales",$H$2:$H$2002,IF(AND(J:J>=1, J:J<=3), $R$1+1, $R$1))
P14P14=SUMIFS($C$2:$C$2002,$G$2:$G$2002,2,$B$2:$B$2002,"Purchase",$H$2:$H$2002,IF(AND(G:G>=1, G:G<=3), $R$1+1, $R$1))
Q14Q14=SUMIFS($D$2:$D$2002,$G$2:$G$2002,2,$B$2:$B$2002,"Purchase",$H$2:$H$2002,IF(AND(H:H>=1, H:H<=3), $R$1+1, $R$1))
R14R14=SUMIFS($C$2:$C$2002,$G$2:$G$2002,2,$B$2:$B$2002,"Sales",$H$2:$H$2002,IF(AND(I:I>=1, I:I<=3), $R$1+1, $R$1))
S14S14=SUMIFS($D$2:$D$2002,$G$2:$G$2002,2,$B$2:$B$2002,"Sales",$H$2:$H$2002,IF(AND(J:J>=1, J:J<=3), $R$1+1, $R$1))
P15P15=SUMIFS($C$2:$C$2002,$G$2:$G$2002,3,$B$2:$B$2002,"Purchase",$H$2:$H$2002,IF(AND(G:G>=1, G:G<=3), $R$1+1, $R$1))
Q15Q15=SUMIFS($D$2:$D$2002,$G$2:$G$2002,3,$B$2:$B$2002,"Purchase",$H$2:$H$2002,IF(AND(H:H>=1, H:H<=3), $R$1+1, $R$1))
R15R15=SUMIFS($C$2:$C$2002,$G$2:$G$2002,3,$B$2:$B$2002,"Sales",$H$2:$H$2002,IF(AND(I:I>=1, I:I<=3), $R$1+1, $R$1))
S15S15=SUMIFS($D$2:$D$2002,$G$2:$G$2002,3,$B$2:$B$2002,"Sales",$H$2:$H$2002,IF(AND(J:J>=1, J:J<=3), $R$1+1, $R$1))
Cells with Data Validation
CellAllowCriteria
R1List2023,2024,2025,2026,2027


Regards
Haree Nagappan
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,333
Members
452,636
Latest member
laura12345

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