SUM if Row+Column > X

indygo

Board Regular
Joined
Dec 2, 2013
Messages
107
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.

1234
10.100.120.250.30
20.050.100.320.40
30.140.130.100.15
40.180.110.160.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.


Thanks in advance
 
Last edited:

Gerald Higgins

Well-known Member
Joined
Mar 26, 2007
Messages
9,115
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
Joined
Dec 2, 2013
Messages
107
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
Joined
May 28, 2005
Messages
42,231
Office Version
365
Platform
Windows
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:

Forum statistics

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

Some videos you may like

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...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top