+ Reply to Thread
Results 1 to 5 of 5

Counting every nth occurrence (with & without a condition)

  1. #1
    Forum Contributor
    Join Date
    02-08-2005
    MS-Off Ver
    Microsoft 365
    Posts
    810

    Counting every nth occurrence (with & without a condition)

    Hi,

    I have a few dozen columns of data and would like from each row to count the number of negative numbers in every 3 occurrences. E.g. in row 2 I’d want to count the negative occurences in B2, E2, H2, K2 etc.

    Also, I’d like to be able to count the total number of occurences along each row, again counting every 3rd occurrence, though this time both negative and positive values.

    Can someone please suggest a formula for each of these two problems?

    Thanks!
    Last edited by andrewc; 09-24-2009 at 09:58 AM.

  2. #2
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,444

    Re: Counting every nth occurrence (with & without a condition)

    Hi,

    Try these:

    =SUMPRODUCT(((MOD(COLUMN(A2:AA2),3))=2)*(A2:AA2<0))
    =SUMPRODUCT(((MOD(COLUMN(A2:AA2),3))=2)*(NOT(A2:AA2="")))
    Rule 1: Never merge cells
    Rule 2: See rule 1

    "Tomorrow I'm going to be famous. All I need is a tennis racket and a hat".

  3. #3
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Counting every nth occurrence (with & without a condition)

    To count the negative values:
    Please Login or Register  to view this content.
    To count all numeric values (assuming there may be text in some cells):
    Please Login or Register  to view this content.
    Does that help?
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  4. #4
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Counting every nth occurrence (with & without a condition)

    if your starting and including b2 then you need to adjust so col b=3 so add 1 to the formula as shown
    =SUMPRODUCT(((MOD(COLUMN(B2:K2)+1,3)=0)*(B2:K2<0)))
    or i suppose just as the others suggested leave it at
    MOD(COLUMN(B2:AG2),3)=2)*......
    just my preference really
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  5. #5
    Forum Contributor
    Join Date
    02-08-2005
    MS-Off Ver
    Microsoft 365
    Posts
    810

    Re: Counting every nth occurrence (with & without a condition)

    Perfect! Thank you all very much

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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