# SUM if Row+Column > X

#### indygo

##### Board Regular
hi guys,

I'm having a little brain freeze here

I would like sum values in cross table xy based on sum of x and y.

 1 2 3 4 1 0.1 0.12 0.25 0.3 2 0.05 0.1 0.32 0.4 3 0.14 0.13 0.1 0.15 4 0.18 0.11 0.16 0.21

<tbody>
</tbody>

For example:

sum values if Column + Row >7.5. We know that there is only one such scenario 4+4 so it equals 0.21
sum values if Column + Row < 4.00. That would be 1-1,2-1,1-2 so 0.10+0.05+0.12 = 0.27

What formula could calculate this automatically based on my X value?

I tried something like =SUMIF(A1:E5,A2:A5+B1:E1>B7,B2:E5) but that doesn't work.

Last edited:

#### Gerald Higgins

##### Well-known Member
If I was doing this, I would use a helper table, like this.

Let's make some assumptions.
Your existing table is in the range A1:E5 (so that the bottom right value of 0.21 is in cell E5).
Your target value of 7.5 or 4.00 or whatever is held in cell F1.
Your helper table is in the range G1:K5.

In cell H2 put this formula . . .
=IF((H\$1+\$G2)>\$F\$1,B2,0)

Then copy this across to the range H2:K5.

Then use this formula . . .
=sum(H2:K5)
which should give you the desired result.

Obviously adapt all cell and range references as required.

#### indygo

##### Board Regular
If I was doing this, I would use a helper table, like this.

Let's make some assumptions.
Your existing table is in the range A1:E5 (so that the bottom right value of 0.21 is in cell E5).
Your target value of 7.5 or 4.00 or whatever is held in cell F1.
Your helper table is in the range G1:K5.

In cell H2 put this formula . . .
=IF((H\$1+\$G2)>\$F\$1,B2,0)

Then copy this across to the range H2:K5.

Then use this formula . . .
=sum(H2:K5)
which should give you the desired result.

Obviously adapt all cell and range references as required.

That's clever, thanks a lot.

#### Peter_SSs

##### MrExcel MVP, Moderator
You can do it directly like this.

<b>Sum</b><br /><br /><table border="1" cellspacing="0" cellpadding="0" style="font-family:Arial,Arial; font-size:8pt; background-color:#ffffff; padding-left:2pt; padding-right:2pt; "> <colgroup><col style="font-weight:bold; width:30px; " /><col style="width:56px;" /><col style="width:56px;" /><col style="width:56px;" /><col style="width:56px;" /><col style="width:56px;" /><col style="width:26px;" /><col style="width:56px;" /></colgroup><tr style="background-color:#cacaca; text-align:center; font-weight:bold; font-size:8pt; "><td > </td><td >A</td><td >B</td><td >C</td><td >D</td><td >E</td><td >F</td><td >G</td></tr><tr style="height:21px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >1</td><td style="font-size:10pt; "> </td><td style="font-size:10pt; text-align:right; ">1</td><td style="font-size:10pt; text-align:right; ">2</td><td style="font-size:10pt; text-align:right; ">3</td><td style="font-size:10pt; text-align:right; ">4</td><td style="font-size:10pt; "> </td><td style="font-size:10pt; "> </td></tr><tr style="height:21px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >2</td><td style="font-size:10pt; text-align:right; ">1</td><td style="font-size:10pt; text-align:right; ">0.1</td><td style="font-size:10pt; text-align:right; ">0.12</td><td style="font-size:10pt; text-align:right; ">0.25</td><td style="font-size:10pt; text-align:right; ">0.3</td><td style="font-size:10pt; "> </td><td style="font-size:10pt; text-align:right; ">0.21</td></tr><tr style="height:21px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >3</td><td style="font-size:10pt; text-align:right; ">2</td><td style="font-size:10pt; text-align:right; ">0.05</td><td style="font-size:10pt; text-align:right; ">0.1</td><td style="font-size:10pt; text-align:right; ">0.32</td><td style="font-size:10pt; text-align:right; ">0.4</td><td style="font-size:10pt; "> </td><td style="font-size:10pt; text-align:right; ">0.27</td></tr><tr style="height:21px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >4</td><td style="font-size:10pt; text-align:right; ">3</td><td style="font-size:10pt; text-align:right; ">0.14</td><td style="font-size:10pt; text-align:right; ">0.13</td><td style="font-size:10pt; text-align:right; ">0.1</td><td style="font-size:10pt; text-align:right; ">0.15</td><td style="font-size:10pt; "> </td><td style="font-size:10pt; "> </td></tr><tr style="height:21px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >5</td><td style="font-size:10pt; text-align:right; ">4</td><td style="font-size:10pt; text-align:right; ">0.18</td><td style="font-size:10pt; text-align:right; ">0.11</td><td style="font-size:10pt; text-align:right; ">0.16</td><td style="font-size:10pt; text-align:right; ">0.21</td><td style="font-size:10pt; "> </td><td style="font-size:10pt; "> </td></tr></table><br /><table style="font-family:Arial; font-size:10pt; border-style: groove ;border-color:#00ff00;background-color:#fffcf9; color:#000000; "><tr><td ><b>Spreadsheet Formulas</b></td></tr><tr><td ><table border = "1" cellspacing="0" cellpadding="2" style="font-family:Arial; font-size:9pt;"><tr style="background-color:#cacaca; font-size:10pt;"><td >Cell</td><td >Formula</td></tr><tr><td >G2</td><td >=SUMPRODUCT(<span style=' color:008000; '>(B1:E1+A2:A5>7.5)</span>*B2:E5)</td></tr><tr><td >G3</td><td >=SUMPRODUCT(<span style=' color:008000; '>(B1:E1+A2:A5<4)</span>*B2:E5)</td></tr></table></td></tr></table>

Last edited:

1,081,767
Messages
5,361,164
Members
400,617
Latest member
barron1

### This Week's Hot Topics

• populate from drop list with multiple tables
Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
• Find list of words from sheet2 in sheet1 before a comma and extract text vba
Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
• Dynamic Formula entry - VBA code sought
Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...