+ Reply to Thread
Results 1 to 13 of 13

Counting Non Blanks and Non Zero's

  1. #1
    Registered User
    Join Date
    04-08-2006
    Posts
    34

    Question Counting Non Blanks and Non Zero's

    How do I count the number of cells in a row that are either not blank or above zero in a non sequential range?

    For example, I want a column in a golf course chart to count the applicable "Par" columns of each of the course holes. Although my sheet has provisions for 18 holes across the page, some courses are only 9 hole courses, so the remaining holes 10-18 are blank in their Par columns.

    In my course summary table, I want a column to be "Number of Holes" which is a calculation of how many Par cells have data in them.

    The par for each course is within the following cells:
    ($C3,$F3,$I3,$L3,$O3,$R3,$U3,$X3,$AA3,$AD3,$AG3,$AJ3,$AM3,$AP3,$AS3,$AV3,$AY3,$BB3)
    Pic to help explain:
    Excel_Count_Non_Blanks.jpg

  2. #2
    Valued Forum Contributor Harribone's Avatar
    Join Date
    02-24-2013
    Location
    Midlands, UK
    MS-Off Ver
    Excel 2019/365
    Posts
    570

    Re: Counting Non Blanks and Non Zero's

    So you want a cell to show the number of holes for that course? This will always be 9 or 18 yes?

    If that is the case then you just need to check if the Par foe hole 18 exsists, if not its a 9 hole course. So lets say A18 is the par for hole 18 (for ease of example).
    In the cell where you want to show the number of holes:

    =IF(A18="",9,18)
    Say thanks, click *

  3. #3
    Registered User
    Join Date
    04-08-2006
    Posts
    34

    Re: Counting Non Blanks and Non Zero's

    Thanks for the quick solution, but alas, there are and will be more cases of smaller "pitch n putt" courses which could have anywhere from 2 holes on up...

  4. #4
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Counting Non Blanks and Non Zero's

    Try

    =INT(LOOKUP(99,3:3,COLUMN(3:3))/3)

    Assuming none of the numbers will be larger than 99.

  5. #5
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Counting Non Blanks and Non Zero's

    Well, after a closer look...looks like numbers can be larger than 99

    Then
    =INT(LOOKUP(9.99999999999999E+307,3:3,COLUMN(3:3))/3)

  6. #6
    Valued Forum Contributor Harribone's Avatar
    Join Date
    02-24-2013
    Location
    Midlands, UK
    MS-Off Ver
    Excel 2019/365
    Posts
    570

    Re: Counting Non Blanks and Non Zero's

    =IF(A1="",0,1)+IF(A1="",0,1)+IF(A1="",0,1)+IF(A1="",0,1)...

    Change the E9 to each holes par cell location. Not an elegant solution but it does the job.
    It will check each cell to see if is blank. If it is blank then 0 is returned else 1 is returned. These are added up to give you the total number of holes for the course.

  7. #7
    Registered User
    Join Date
    04-08-2006
    Posts
    34

    Re: Counting Non Blanks and Non Zero's

    Thanks guys, although I liked the look of Jonmo1's solution, it didn't work quite right, and I didn't understand it enough to be able to adjust it. It sure seems interesting though. I utilized Harribone's solution and it works good, albeit like mentioned, not an elegant solution, but no one will see it anyway, Thanks very much Harribone.

    Is it possible to turn that into a SUMPRODUCT formula somehow, or does the non-sequential range screw that up too?

  8. #8
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Counting Non Blanks and Non Zero's

    In what way did it not work?

    Can you give example of situtation that it produced the wrong result?
    What result DID it return, and what result were you expecting and why?

    Can you post an actual book instead of pictures?

  9. #9
    Registered User
    Join Date
    04-08-2006
    Posts
    34

    Re: Counting Non Blanks and Non Zero's

    It seemed to post a result of either 0 or 20 when I was expecting either 0,9,18, or other, not 20 though... Maybe due to my error in copy-pasteing, not sure, but see attached,

    courseHOLECOUNTformula.xlsx

  10. #10
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Counting Non Blanks and Non Zero's

    Ah, circular references.

    Try this in BE3 and filled down.
    =INT(LOOKUP(9.99999999999999E+307,A3:BD3,COLUMN(A3:BD3))/3)

    It will return #N/A if the whole row is blank.
    But that can be corrected if you need it.
    What result would you like it to show in that case?

  11. #11
    Registered User
    Join Date
    04-08-2006
    Posts
    34

    Re: Counting Non Blanks and Non Zero's

    Yes that does work better; instead of #N/A on blank rows (blank rows mean I have a course without enough hole data), can the cell say "Update Required" or something?

    Also, and more importantly, can you briefly explain what your formula is doing so I can learn from that approach?

  12. #12
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Counting Non Blanks and Non Zero's

    Sure,

    The 9.999999.... is basically just a VERY Large number. The largest number allowed in a cell.
    Thus ensuring it is larger than any number in the range.
    The lookup then finds the last number entry (furthest to the right)
    And returns the corresponding Column #.

    It then devides that number by 3 (you have groups of 3 cells per hole).
    And then INT basically rounds down the result of that devision to a whole number.


    Since you're file was an xlsx estention, I assume you have xl2007 or higher.
    So to make it say "Update required" instead of #N/A, we can use IFERROR

    =IFERROR(INT(LOOKUP(9.99999999999999E+307,A3:BD3,COLUMN(A3:BD3))/3),"Update Required")

    Hope that helps.

  13. #13
    Registered User
    Join Date
    04-08-2006
    Posts
    34

    Re: Counting Non Blanks and Non Zero's

    Perfect. Thank you very much for the solution, and the explanation,

+ 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