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

#### Simonc64

##### Board Regular
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?

### 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
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
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
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.

#### Simonc64

##### Board Regular
Seems to work perfectly jason thank you !

Replies
5
Views
275
Replies
2
Views
214
Replies
0
Views
154
Replies
4
Views
92
Replies
3
Views
89

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.

### Which adblocker are you using?

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

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