Google Sheets: (a) calculate the sum of every other column in a sheet (b) UPTO the column you're in (c) Simplify Row 14 formula from example

p_s

New Member
Joined
Sep 23, 2020
Messages
30
Office Version
  1. 2019
Platform
  1. Windows
  2. Mobile
  3. Web
Hi,

Hope y'all can help me out.
  1. I need to calculate every other cell in a selection (in this example $D2:$M2)

  2. I need to stop the calculation at the cell we are in. [Detailed in the spreadsheet below]

  3. Row 14: is there an easier way to calculate this? This is what I am doing currently.
I've input it into the XL2BB, but it this query is for Google Sheets.

Book1
ABCDEFGHIJKLM
1Qty Already haveQty RequiredCost/MaterialNeededRemainingNeededRemainingNeededNeededRemainingNeededRemaining
22,00,000Value of Last Column (since this is cumulative)$ 0.008,898IF($A$2 - [SUM(of Cell D2, F2, H2,J2,L2,N2) but only uptil Column E]<=0,value of calc, 0)0$A$2 - [SUM(of Cell D2, F2, H2,J2,L2,N2) but only uptil Column G]<=0,value of calc, 0)0$A$2 - [SUM(of Cell D2, F2, H2,J2,L2,N2) but only uptil Column I]<=0,value of calc, 0)4,044$A$2 - [SUM(of Cell D2, F2, H2,J2,L2,N2) but only uptil Column K]<=0,value of calc, 0)0$A$2 - [SUM(of Cell D2, F2, H2,J2,L2,N2) but only uptil Column M]<=0,value of calc, 0)
310,00010188$ 1,915,344.009,588000000000
41,2341327$ 123,012.9010,1468,9124,68913,6016,75620,357020,357020,357
512,41212938$ 6,805,388.002,52301,16701,68000000
63$ 8.9121,25,27521,25,2757,52,83528,78,11019,99,13948,77,2492,03,70950,80,958050,80,958
731$ 961.003,98,9553,98,9552,05,9026,04,8575,09,88011,14,73745,73811,60,475011,60,475
833$ 1,085.701,37,8921,37,89266,9632,04,8551,68,5573,73,41218,5523,91,96403,91,964
9129$ 16,641.0024,50424,50411,08535,58926,20261,7913,22265,013065,013
101990$ 3,960,100.006,7716,7713,1629,9337,13317,06668717,753017,753
111540$ 2,371,600.0000002,5192,51902,51902,519
124460$ 19,891,600.000000000000
130$ 0.000000000000
14Material Cost:(SUMPRODUCT(E$2:E$13,$C$2:$C$13))Material Cost:(SUMPRODUCT(G$2:G$13,$C$2:$C$13))-$E14Material Cost:(SUMPRODUCT(I$2:I$13,$C$2:$C$13))-SUM($E14,$G14)Material Cost:(SUMPRODUCT(K$2:K$13,$C$2:$C$13))-SUM($E14,$G14,$I14)Material Cost:(SUMPRODUCT(M$2:M$13,$C$2:$C$13))-SUM($E14,$G14,$I14,$K14)
Sheet1
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
I'm assuming there's no way to do this.... ?
 
Upvote 0
For Rows: E, G, I, K etc I used the following formula (This is for G2, if it was D2, all the G2s would become D2s)
Excel Formula:
=SUMPRODUCT(--(MOD(COLUMN($D2:G2)-COLUMN(I6)+1,2)=1),$D2:G2)-$A2

For Row 14, I left E14 as it is

For G14 onwards the formula became a copyable:
Excel Formula:
= SUMPRODUCT(G$2:G$13,$A$2:$A$13)-SUMPRODUCT(E$2:E$13,$A$2:$A$13))

I also used an IF Statement around both formulas to wrap around is so that if the above formula is <=0 the returned value should be 0.
 
Upvote 0
How about in E2
Excel Formula:
=MAX($D2-$A2,0)
if G2
Excel Formula:
=MAX(SUMIFS($D2:F2,$D$1:F$1,"Needed")-$A2,0)
 
Upvote 0
How about in E2
Excel Formula:
=MAX($D2-$A2,0)
if G2
Excel Formula:
=MAX(SUMIFS($D2:F2,$D$1:F$1,"Needed")-$A2,0)
I had thought of using sumifs, but if users add more columns or decide to change the header it will create problems. As a result, I wanted the formula to stay independent of the header. But I like the idea of using MAX () instead of an IF statement. It's a great suggestion, thanks. And yes, E2 can totally be an independant function. I just made it use the formula listed above for the sake of similarity.

Thank you!
 
Upvote 0
Your formula from post#3 does not give the results you show in post#1, should it be
Excel Formula:
=MAX(SUMPRODUCT(--(MOD(COLUMN($D2:G2),2)=0),$D2:G2)-$A2,0)
If columns are added, then this formula will fail, whereas the sumifs will still be correct.
 
Upvote 0
Solution
Your formula from post#3 does not give the results you show in post#1, should it be
Excel Formula:
=MAX(SUMPRODUCT(--(MOD(COLUMN($D2:G2),2)=0),$D2:G2)-$A2,0)
If columns are added, then this formula will fail, whereas the sumifs will still be correct.
Why will it fail? Columns will be added at the end which will look exactly as these columns... In this formula, we skip 1 column in our sum, we could further change it to skip more than 1 column if need be.
 
Upvote 0
When you said
but if users add more columns or decide to change the header it will create problems
I thought you were talking about new inserting columns into the data, as that is the only way it would affect the formula.
 
Upvote 0
Assume the pairs of columns that are the same base color, are for 1 item, and each row are the different parts.

We might have some parts, which is Column A

Column D is the parts need to make the item, and Column E is (Parts need - Parts in stock) and this continues on and on, the 1st item is 1st priority, 2nd is next. and etc. Row 14 is the Cost of the new parts needed for EACH item, not cumulative. (And this contines for F:M).

If we need to add more items to make we will add the same set of columns (parts needed, and cumulative parts need) at the end.
 
Upvote 0

Forum statistics

Threads
1,223,634
Messages
6,173,475
Members
452,516
Latest member
archcalx

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