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