Adding Values with No Consistent Number of Rows or Columns

LarsAustin

New Member
Joined
Feb 27, 2016
Messages
16
Hello,

I am trying to find an efficient formula that will add the values in B4:F4 (yellow cells) and then subtract it from the value in A1 and put it in cell A2. But then I want the same for values in G4:J4 (gold cells) and then subtract it from the value in G1 and put in cell G2. And so on the next.

The pattern is that it will add the values in row 4 but only up to a point where the next adjacent cell in Row 1 is not equal to zero.

I hope clearly explain what I want to achieve.

Thank you.

A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
1
960
360
360
360
2
870
330
240
330
3
4
30
0
30
0
30
0
0
0
30
0
0
30
30
30
0
0
30
0
0
30
0

<tbody>
</tbody>
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Assuming column U is the last column:

A2: =IF(A1>0,A1-SUM(A4:$U4)+SUM(B1:$U1)-SUM(B2:$U2),"") copy to the right
 
Upvote 0
.. or if you cannot just drag the formula to the right (it looks like you might possibly have merged cells in between), you could take the central part of Stephen's formula
=A1-SUM(A4:$U4)+SUM(B1:$U1)-SUM(B2:$U2)
and put it in A2 and then copy to G2, K2, etc

Note that whichever formula you use, the correct results will not appear until you have filled across to the other relevant cells in row 2.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,216,269
Messages
6,129,813
Members
449,538
Latest member
cookie2956

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