XL: How to Sum Either Odd or Even Rows Only

Last reviewed: February 2, 1998
Article ID: Q136738
The information in this article applies to:
  • Microsoft Excel 97 for Windows
  • Microsoft Excel for Windows 95, versions 7.0, 7.0a
  • Microsoft Excel for Windows, versions 3.0, 4.0, 5.0, 5.0c
  • Microsoft Excel 98 Macintosh Edition
  • Microsoft Excel for the Macintosh, versions 3.0, 4.0, 5.0, 5.0a
  • Microsoft Excel for Windows NT, version 5.0

SUMMARY

When you use any of the worksheet functions in the Microsoft products listed at the beginning of this article, and you have a range argument that includes either hidden rows or columns, the cells in these hidden areas are still used by the function. For example, if you have the following in a worksheet

   A1: 1
   A2: 1
   A3: 1
   A4: =SUM(A1:A3)

the SUM function in cell A4 returns a value of 3. If you then hide Row 2, the SUM function still returns a value of 3.

MORE INFORMATION

If you would like to sum only the Odd or the Even rows in a range, instead of trying to hide rows, which does not work in this case, you can use the following formulas.

Odd Rows

   =SUM(IF(MOD(ROW(A1:A3),2)=1,A1:A3,0))

If you enter this as an array formula in cell A4 in the above example, it returns a value of 2.

NOTE: To enter a formula as an array formula in Microsoft Excel for Windows, press CTRL+SHIFT+ENTER. In Microsoft Excel for the Macintosh, press COMMAND+RETURN.

Even Rows

   =SUM(IF(MOD(ROW(A1:A3),2)=0,A1:A3,0))

If you enter this as an array formula in cell A4 in the above example, it returns a value of 1.

NOTE: If you still want to hide rows for the above example, the two functions given will still work as outlined.


Additional query words: 3.00 4.00 5.00 5.00c 7.00 5.00a 5.00c 7.00a 97 98
XL98 XL97 XL7 XL5 XL4 XL3
Keywords : xlformula
Version : WINDOWS:3.0,4.0,5.0,5.0c,7.0,7.0a,97; MACINTOSH:3.0,4.0,5.0,5.0a,98
Platform : MACINTOSH WINDOWS
Issue type : kbhowto kbinfo


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: February 2, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.