adding every second cell in a row
Author Message
adding every second cell in a row

is there any easy way to add every second cell (a1+c1+e1.....) in one row

Thanks

Sven-Erik Nygren

Wed, 18 Jun 1902 08:00:00 GMT
adding every second cell in a row
Hello Sven-Erik,

Use the following array formula to add the odd numbers,as you request:

=SUM(IF(MOD(COLUMN(1:1),2),1:1,0))

Hold down Ctrl+Shift as you enter the formula to create an array
formula.Exccel will add {} around it.

If you want the even numbers, use:

=SUM(IF(MOD(COLUMN(1:1),2),0,1:1))

If you need to do this in VBA, use:

OddSum = [SUM(IF(MOD(COLUMN(1:1),2),1:1,0))]
MsgBox OddSum

HTH,

John Green
Sydney
Australia

Please post all replies to NewsGroups

Quote:

> Subject: adding every second cell in a row
> Date: Sat, 4 Mar 2000 20:09:47 +0200
> Newsgroups: microsoft.public.excel.programming

> is there any easy way to add every second cell (a1+c1+e1.....) in one row

> Thanks

> Sven-Erik Nygren

Wed, 18 Jun 1902 08:00:00 GMT
adding every second cell in a row
Sven-Erik,

If you only want to add up every other cell in part of a row, try this array formula
assuming the first cell is C3 and the range C3:X3:

=SUM((MOD(COLUMN(C3:X3),2)=MOD(COLUMN(C3),2))*C3:X3)

again to be entered with <Shift><Ctrl><Enter>.

To add every N'th cell in a row range use:

=SUM((MOD(COLUMN(C3:X3),N)=MOD(COLUMN(C3),N))*C3:X3)

For a column the similar formula would be:

=SUM((MOD(ROW(C12:C100),N)=MOD(ROW(C12),N))*C12:C100)

assuming first cell C12 and range C12:C100.

Med venlig hilsen
LeoH

sven-erik nygren skrev i meddelelsen ...

Quote:
>is there any easy way to add every second cell (a1+c1+e1.....) in one row

>Thanks

>Sven-Erik Nygren

Wed, 18 Jun 1902 08:00:00 GMT

 Page 1 of 1 [ 3 post ]

Relevant Pages