+ Reply to Thread
Results 1 to 10 of 10

Counting Negative Values in a Range

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

    Counting Negative Values in a Range

    Hi,

    I have a long list of numbers in column A. Can someone please suggest a formula that will count the number of times that a negative value in column A is followed immediately by another negative value?

    Thanks!
    Last edited by andrewc; 12-14-2012 at 07:33 AM.

  2. #2
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Counting Negative Values in a Range

    One simple way is this.

    Assuming your data start in A2, in B2 and copy down put this.

    =IF(AND(A2<0,A3<0),1,"")

    This will be a helper and hidden-if you like- column.

    Then use =COUNTIF(B2:B100,1)
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

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

    Re: Counting Negative Values in a Range

    Thanks for the quick response!

    Rather than using a helper column, is it possible instead to do this using a single array formula?

  4. #4
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Counting Negative Values in a Range

    Probably. I'll take a look on this, BUT always my suggestion is to use a helper column using simple formula, rather than complicate array formula, special if you have many many rows.

  5. #5
    Forum Contributor
    Join Date
    11-11-2012
    Location
    Muscat, Oman
    MS-Off Ver
    Office 365
    Posts
    521

    Re: Counting Negative Values in a Range

    =countif($a$1:$a$999"<0")

  6. #6
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Counting Negative Values in a Range

    Thi will do what you want, but pls, think my suggestion in my previous post.

    =MAX(FREQUENCY(IF(A2:A100<0,ROW(A2:A100)),IF(A2:A100>=0,ROW(A2:A100))))

    This is an Array formula.

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

    Re: Counting Negative Values in a Range

    Thank you.

    I would be grateful to see how to handle such a problem using an array if anyone has suggestions

    Thanks!

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

    Re: Counting Negative Values in a Range

    Wow, that's great, thank Fotis!

  9. #9
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Counting Negative Values in a Range

    You are welcome.

    Thanks for the reb*

  10. #10
    Registered User
    Join Date
    12-13-2012
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Counting Negative Values in a Range

    If your numbers are in A1:A25, how about:

    =SUMPRODUCT(--(A1:A24<0),--(A2:A25<0))

    or just

    =SUMPRODUCT((A1:A24<0)*(A2:A25<0))


    Cheers,
    RD
    Last edited by rda51; 12-18-2012 at 09:17 AM.

+ 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