+ Reply to Thread
Results 1 to 6 of 6

Excel 2007 : COUNTIF gives undesired result

  1. #1
    Registered User
    Join Date
    04-08-2012
    Location
    Abbotsford, BC, Canada
    MS-Off Ver
    Excel 2007
    Posts
    17

    COUNTIF gives undesired result

    Hello,
    The formula, =COUNTIF(H7:H31,">0")counts the number of cells with positive numbers which is fine.

    The formula, =COUNTIF(H7:H31,"<0")counts the cells with negative number in them. Also fine.

    However, the formula, =COUNTIF(H7:H31,"<>0") Counts all cells (25) before any data, positive or negative is introduced and does not count when new entries are introduced.

    I need a count whether positive or negative entries are entered in the cells.

    Please, any help would be greatly appreciated.

    Buscador

  2. #2
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: COUNTIF gives undesired result

    Try

    =SUMPRODUCT(--(H7:H31<>""),--(H7:H31<>0))

  3. #3
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: COUNTIF gives undesired result

    Have you tried this ? ...
    Please Login or Register  to view this content.
    Or if you don't want to count zeros
    Please Login or Register  to view this content.
    Last edited by Marcol; 07-03-2012 at 12:33 PM.
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

  4. #4
    Forum Guru
    Join Date
    05-24-2011
    Location
    India
    MS-Off Ver
    Office 2021
    Posts
    2,237

    Re: COUNTIF gives undesired result

    If you don't want to count zeros,

    =SUM(COUNTIF(H7:H31,{">0","<0"}))
    Regards,
    Haseeb Avarakkan

    __________________________________
    "Feedback is the breakfast of champions"

  5. #5
    Registered User
    Join Date
    04-08-2012
    Location
    Abbotsford, BC, Canada
    MS-Off Ver
    Excel 2007
    Posts
    17

    Re: COUNTIF gives undesired result

    Thank you all, guys, for your help. Finally, I used Marcol's suggestion not to count zeros which worked perfectly.
    Your help, from the three of you, was very much appreciated.

    Buscador happy camper.

  6. #6
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: COUNTIF gives undesired result

    @ Haseeb
    Nice one again!
    I gave up trying arrays with COUNTIF() a long time ago, I never thought of wrapping it in SUM()

+ 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