Sum Value in Every 2nd Cell in a Row, allowing for Columns to be Inserted

Simonc64

Board Regular
Joined
Feb 15, 2007
Messages
223
Hi I have a sheet, currently say with values in A1, A2, A3 and A4

In cell A5 i want to sum the values of A2+A4 (I know i can simply type =A2+A4 but my problem isn't that simple, this is just a scenario for ease of explanation), possibly using the MOD function? Something like where MOD(COLUMNS($A$2,A4)/2)=0 ?

I also want my sum value to update, say if someone inserted two columns, A5 and A6, meaning my sum calculation moved to A7, but calculated A2+A4+A6

Does that make any sense to anyone?

All help gratefully received
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.

jasonb75

Well-known Member
Joined
Dec 30, 2008
Messages
14,559
Office Version
  1. 365
Platform
  1. Windows
Those are rows, not columns. Inserting columns would move your sum across the sheet (left to right), not down.

See if this does what you want it to
Excel Formula:
=SUMPRODUCT(A$2:INDEX(A:A,ROW()-1)*ISEVEN(ROW(A$2:INDEX(A:A,ROW()-1))))
 

Simonc64

Board Regular
Joined
Feb 15, 2007
Messages
223
Those are rows, not columns. Inserting columns would move your sum across the sheet (left to right), not down.

See if this does what you want it to
Excel Formula:
=SUMPRODUCT(A$2:INDEX(A:A,ROW()-1)*ISEVEN(ROW(A$2:INDEX(A:A,ROW()-1))))
Apologies Jason youre totally right - been a long day already!

So i meant, values in A1,B1, C1 and D1 with the sum in E1 (B1+D1)

Two more columns entered with values in E1 and F1, so sum ends up in G1 but sums (B1+D1+F1)

Thanks for the code, i will let you know
 

jasonb75

Well-known Member
Joined
Dec 30, 2008
Messages
14,559
Office Version
  1. 365
Platform
  1. Windows
been a long day already!
And it's only just started 🤯

Going across instead of down you will need this version
Excel Formula:
=SUMPRODUCT($A2:INDEX(2:2,COLUMN()-1)*ISEVEN(COLUMN($A2:INDEX(2:2,COLUMN()-1))))
Which I was about to post originally, then noticed that the references were for rows so I changed it.
 

Forum statistics

Threads
1,148,007
Messages
5,744,319
Members
423,861
Latest member
Ka3EeM

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
Top