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,

To add to John's answer.
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  
 
 [ 3 post ] 

 Relevant Pages 

1. how to delete every second row

2. duplicating every second row

3. Deleting every second row?

4. Please - Macro that deletes every second row

5. inserting a row to every second line.

6. re : choose every second row

7. delete every second row

8. Deleting every second row

9. every second row

10. duplicating every second row


 
Powered by phpBB® Forum Software © phpBB Group