Results 1 to 7 of 7
Thread: Sumif (2003)

20080222, 15:49 #1
 Join Date
 Jan 2001
 Posts
 1,418
 Thanks
 1
 Thanked 0 Times in 0 Posts
Sumif (2003)
Please see attached workbook. What I would like to do is total by month all products received (i. e., positive numbers) and all products returned (i. e., negative numbers, on their respective worksheets. Any ideas? Thanks in advance.

20080222, 16:04 #2
 Join Date
 Mar 2002
 Posts
 84,353
 Thanks
 0
 Thanked 29 Times in 29 Posts
Re: Sumif (2003)
The data table is not in a suitable format. You should put them in a database tablelike format:
<table border=1><td>Supplier</td><td>Month</td><td>Product</td><td>Number</td><td>Supplier 1</td><td align=right>January07</td><td>Hammers</td><td align=right> (533)</td><td>Supplier 1</td><td align=right>January07</td><td>Wrenches</td><td align=right>213 </td><td>Supplier 1</td><td align=right>January07</td><td>Axes</td><td align=right>(34)</td><td>Supplier 2</td><td align=right>January07</td><td>Hammers</td><td align=right>(465)</td><td>Supplier 2</td><td align=right>January07</td><td>Wrenches</td><td align=right>956 </td><td>Supplier 2</td><td align=right>January07</td><td>Axes</td><td align=right>989 </td></table>
You can then use SUMPRODUCT formulas as discussed frequently in this forum.

20080222, 16:56 #3
 Join Date
 Jul 2002
 Location
 Pittsburgh, Pennsylvania, USA
 Posts
 11,225
 Thanks
 14
 Thanked 342 Times in 335 Posts
Re: Sumif (2003)
<P ID="edit" class=small>(Edited by sdckapr on 22Feb08 09:56. Added PS)</P>In Hammers!B2:
=SUMIF(OFFSET('Monthly Totals'!$A$4,0,<font color=448800>3</font color=448800>*(MONTH($A2)1)+<font color=red>1</font color=red>,<font color=blue>5</font color=blue>,1),">0")
In Hammers!C2
=SUMIF(OFFSET('Monthly Totals'!$A$4,0,<font color=448800>3</font color=448800>*(MONTH($A2)1)+<font color=red>1</font color=red>,<font color=blue>5</font color=blue>,1),"<0")
Then select B2:C2 and copy/Autofill down the columns
The <font color=448800>3</font color=448800> is the number of items (Hammer, Wrench, Ax)
The <font color=blue>5</font color=blue> is for the number of supplier rows (Suppliers 15)
The "+<font color=red>1</font color=red>" is for the Item number in the list (Hammer is 1, Wrench is 2, Axe is 3)
Therefore for wrenches the "+1" becomes "+2"
in Wrenches!B2
=SUMIF(OFFSET('Monthly Totals'!$A$4,0,3*(MONTH($A2)1)+<font color=red>2</font color=red>,5,1),">0")
Wrenches!C2
=SUMIF(OFFSET('Monthly Totals'!$A$4,0,3*(MONTH($A2)1)+<font color=red>2</font color=red>,5,1),"<0")
And for axes the "+1" becomes "+3"
Axes!B2
=SUMIF(OFFSET('Monthly Totals'!$A$4,0,3*(MONTH($A2)1)+<font color=red>3</font color=red>,5,1),">0")
Axes!C2
=SUMIF(OFFSET('Monthly Totals'!$A$4,0,3*(MONTH($A2)1)+<font color=red>3</font color=red>,5,1),">0")
Again copy B2:C2 down the columns as needed in both sheets. If there are more suppliers, or more items adjust accordingly
Steve
PS
If you want to define a range (could be a defined name) for the dataset, instead of offset you could use index:
Hammers!B2/C2:
=SUMIF(INDEX('Monthly Totals'!$B$4:$M$8,0,3*(MONTH($A2)1)+1),">0")
=SUMIF(INDEX('Monthly Totals'!$B$4:$M$8,0,3*(MONTH($A2)1)+1),"<0")
The others adapt as well changing the +1 to +2(wrenches), and +3 (Axes)

20080222, 17:28 #4
 Join Date
 Jan 2001
 Posts
 1,418
 Thanks
 1
 Thanked 0 Times in 0 Posts
Re: Sumif (2003)
Thanks, Steve, I really appreciate it!

20080222, 18:28 #5
 Join Date
 Jan 2001
 Posts
 1,418
 Thanks
 1
 Thanked 0 Times in 0 Posts
Re: Sumif (2003)
Steve,
Quick question: what function does the first zero and the second positive one (after the five) serve? Incase I might want to adapt this to another scenario>
Thanks again.

20080222, 19:16 #6
 Join Date
 Jul 2002
 Location
 Pittsburgh, Pennsylvania, USA
 Posts
 11,225
 Thanks
 14
 Thanked 342 Times in 335 Posts
Re: Sumif (2003)
The first zero indicates that you offset zero rows from A4 (ie you stay in row 4).
The second 1 indicates that you are defining only 1 column of data.
OFFSET('Monthly Totals'!$A$4,0,3*(MONTH($A2)1)+1,5,1)
1) So you start at 'Monthly Totals'!$A$4
2) Go 0 rows down
3) Go 3*(MONTH($A2)1)+1 columns to the right
[If A2 is February:
=3*(MONTH($A2)1)+1
=3*(21)+1
=3*1+1=4
4 columns from A is Column E. At this point you are at E4
The last 2 parameters define the size of the range
4) the number of rows is 5
[Range goes from 4 to 8]
5) The number of columns is 1
So the range defined by the offset is E4:E8 the data for Hammers in February
Steve

20080222, 21:31 #7
 Join Date
 Jan 2001
 Posts
 1,418
 Thanks
 1
 Thanked 0 Times in 0 Posts
Re: Sumif (2003)
Thanks Steve.