+ Reply to Thread
Results 1 to 8 of 8

SUM only cells that contain odd numbers.

  1. #1
    Registered User
    Join Date
    02-16-2013
    Location
    Folsom, CA
    MS-Off Ver
    Excel 2010
    Posts
    47

    SUM only cells that contain odd numbers.

    Say I have a column of numbers and I want to add up only the odd numbers. I tried SUMIF(A1:A10,"ISODD",A1:A10) to no avail.

    But, curiously, if I altered the formula to SUMIF(A1:A10,">5",A1:A10) it did in fact add up only the numbers that were > 5.

    The syntax seems the same to me, so why the difference?

    So then I tried =SUMPRODUCT(--ISODD(A1:A10),A1:A10) also to no avail.

    But VERY curiously, the following formula did work to add up just the odd rows =SUMPRODUCT(--ISODD(ROW(A1:A10)),A1:A10)

    Can someone explain (in simple terms, please) what concept(s) I'm missing? I don't want to just ask someone to write the formula for me, I want to understand why it works. Thanks!
    Attached Files Attached Files

  2. #2
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: SUM only cells that contain odd numbers.

    dzugan,

    With your first try, you can't put a function inside of a function the way you did.

    The best way to understand how as formula works is to place your cursor of the formula and then Evaluate.

    Evaluate Formula
    • Click on the cell with the formula >> Ribbon >> Formulas >> Formula Auditing >> Evaluate Formula

    Here's a discussion you might find interesting to help in your learning https://www.excelbanter.com/excel-di...d-numbers.html

    =SUMPRODUCT(--(A1:A10),--(MOD(ROW(A1:A10),2)=1))

    Again, if you evaluate the formula above that will explain what's happening much quicker than trying to type out all of the steps.

    I hope this helps...
    HTH
    Regards, Jeff

  3. #3
    Valued Forum Contributor Root_'s Avatar
    Join Date
    07-29-2017
    Location
    _
    MS-Off Ver
    2010+
    Posts
    484

    Re: SUM only cells that contain odd numbers.

    Some Excel functions do not work with ranges, but they accept arrays.

    ISODD is one of them. That's why it works with ROW(A1:A10).

    For your formula to work, just add +0:

    =SUMPRODUCT(--ISODD(A1:A10+0),A1:A10)

  4. #4
    Registered User
    Join Date
    02-16-2013
    Location
    Folsom, CA
    MS-Off Ver
    Excel 2010
    Posts
    47

    Re: SUM only cells that contain odd numbers.

    Is there any kind of listing of which functions accept what? When I look under the alphabetical listing of Excel functions on the Microsoft website it doesn't seem to explain this.

    https://support.office.com/en-us/art...rs=en-US&ad=US

    Thanks

  5. #5
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2404 Win 11 Home 64 Bit
    Posts
    23,855

    Re: SUM only cells that contain odd numbers.

    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  6. #6
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: SUM only cells that contain odd numbers.

    Here is another one
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  7. #7
    Registered User
    Join Date
    02-16-2013
    Location
    Folsom, CA
    MS-Off Ver
    Excel 2010
    Posts
    47

    Re: SUM only cells that contain odd numbers.

    Hi,

    I found a nice shortcut to evaluating a formula with F9. I guess my disappointment is that the evaluation only shows WHERE my problem is. This is of course useful info, but it still doesn't tell me WHY it doesn't work or HOW to fix it. Looking at Root's explanation below, it looks like I need more study on the characteristics of the ISODD function and the differences between ranges and arrays. Study on!

    Thanks

  8. #8
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,150

    Re: SUM only cells that contain odd numbers.

    Quote Originally Posted by dzugan View Post
    I found a nice shortcut to evaluating a formula with F9
    F9
    Shift+F9
    Ctrl+Alt+F9
    Ctrl+Alt+Shift+F9

    https://support.office.com/en-us/art...9-9b7213f0040f

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Compare two cells with comma delimited numbers and display the numbers that are NOT duplic
    By ks100 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-13-2014, 02:22 PM
  2. Replies: 7
    Last Post: 02-27-2014, 10:56 PM
  3. [SOLVED] Delete text, split numbers to two cells and store as numbers
    By Steve_123 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-10-2014, 09:51 AM
  4. Replies: 3
    Last Post: 01-08-2014, 10:50 PM
  5. [SOLVED] How to merge a numbers from 3 cells, eliminate repetitive numbers, and sort such numbers?
    By david gonzalez in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 10-22-2012, 11:59 AM
  6. [SOLVED] Vlookup formula - return only numbers for cells containing text and numbers
    By Andrew E Smith in forum Excel General
    Replies: 11
    Last Post: 07-03-2012, 06:07 AM
  7. change 2000 cells (negative numbers) into positive numbers
    By lisbern in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-16-2006, 01:00 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1