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

All help gratefully received

### Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.

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

#### Simonc64

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

Replies
12
Views
197
Replies
3
Views
83
Replies
7
Views
170
Replies
5
Views
350
Replies
2
Views
248

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

1,152,116
Messages
5,768,211
Members
425,459
Latest member
Danniey

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

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