+ Reply to Thread
Results 1 to 3 of 3

Issue using sumproduct forumla to count every 2nd cell

  1. #1
    Registered User
    Join Date
    11-10-2011
    Location
    Rotorua, New Zealand
    MS-Off Ver
    Excel 2003
    Posts
    8

    Issue using sumproduct forumla to count every 2nd cell

    I am using a formula that counts every 2nd cell in a row, this is what I use:

    =SUMPRODUCT((MOD(COLUMN(J4:SZ4),2)=0)*(J4:SZ4))

    This works as expected, it sums any number in every 2nd row from J4 onwards (J4, L4, N4...etc)

    What I want to do is run a similar formula that counts the other cells (K4, M4, O4...etc) but when I use the same formula only starting from K4 instead of J4 it doesn't work. I use this forumla:
    =SUMPRODUCT((MOD(COLUMN(K4:TA4),2)=0)*(K4:TA4))

    It tells me that it omits adjacent cells (which I want it to as I don;t want it tallying J4) but then goes on to count cells L4, N4...etc instead of the K4, M4, O4 cells that I want summed.

    I run the formula's in cells E4:=SUMPRODUCT((MOD(COLUMN(J4:SZ4),2)=0)*(J4:SZ4)) and F4:=SUMPRODUCT((MOD(COLUMN(K4:TA4),2)=0)*(K4:TA4)) though I doubt it makes a differnce where I run them from.

    I have results in cells J4-AA4 that represent different data I want summed as two seperate results. Not sure what I am missing, can anyone set me straight please?
    Thanks!

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Issue using sumproduct forumla to count every 2nd cell

    The MOD() trick is creating an array of 0,1 answers, and only summing the cells that gave a 0 result. To get the other cells, change that to =1.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    11-10-2011
    Location
    Rotorua, New Zealand
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: Issue using sumproduct forumla to count every 2nd cell

    Huh, that was to easy! Thanks, makes sense once I read through the formula and made the adjustment you suggested...can go walk my dogs with a clearer head now, was driving me nuts! Thanks again

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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