+ Reply to Thread
Results 1 to 7 of 7

Count until a condition is met

  1. #1
    Forum Contributor
    Join Date
    01-25-2010
    Location
    Virginia
    MS-Off Ver
    Excel 2013
    Posts
    104

    Count until a condition is met

    Attached is a sample worksheet.

    The Status column contains a small number of possible values. I want to only count records whose Status value is either "Yes" or "No", and I only want to count until the sum of the "Yes" and "No" records equals the number specified in cell F2.

    In other words, in this sample worksheet, the Number Yes result should be 4, and the Number No result should be 2 (and then the counting would stop because 6 records have been counted).

    What is the best formula to do this?
    Attached Files Attached Files
    Last edited by SueWithQuestion; 02-23-2011 at 08:26 AM.

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,169

    Re: Count until a condition is met

    Hi Sue,
    Try the attached.
    Attached Files Attached Files
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Forum Contributor
    Join Date
    01-25-2010
    Location
    Virginia
    MS-Off Ver
    Excel 2013
    Posts
    104

    Re: Count until a condition is met

    Thank you so much for your quick reply. Your formula is close, but not quite what I'm looking for.

    The result for the "Number Yes" formula should be 4, not 6, because I only want to keep counting until the sum of "Number Yes" and "Number No" equals the "Goal" value of 6.

    Any suggestions?

  4. #4
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,169

    Re: Count until a condition is met

    Here it is, now that I understand the question.
    I needed a helping column and a indirect range cell, but this will do it.

    You might be able to combine them into a single equation but I'm not that smart (or motivated)
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    01-25-2010
    Location
    Virginia
    MS-Off Ver
    Excel 2013
    Posts
    104

    Re: Count until a condition is met

    Thank you again!

    I would like to figure out a way to not have to add a helper column to do this.

    Can anyone else offer another suggestion?

  6. #6
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Count until a condition is met

    I'd still avoid repeating expensive calculations but you could use a single helper cell rather than a column full

    Please Login or Register  to view this content.
    the above Array will determine the last "valid" row - ie the point at which the Goal is reached

    Please Login or Register  to view this content.
    Though you could avoid use of G2 it makes little sense to do so.
    The end point is constant for both Yes & No results thus there is little point recalculating that value more than once.

  7. #7
    Forum Contributor
    Join Date
    01-25-2010
    Location
    Virginia
    MS-Off Ver
    Excel 2013
    Posts
    104

    Re: Count until a condition is met

    Thank you 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