+ Reply to Thread
Results 1 to 4 of 4

Formula that counts specific values, but stops at the point that the value changes.

  1. #1
    Registered User
    Join Date
    09-29-2014
    Location
    New Zealand
    MS-Off Ver
    2010
    Posts
    14

    Formula that counts specific values, but stops at the point that the value changes.

    Is there a formula that will count the number of rows that contain a value (i.e. count the rows that have an "L" in column A) but will stop the total as soon as the value changes in the first instance.

    I.e. (column b would be the formula in the below example)

    Please Login or Register  to view this content.

  2. #2
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Formula that counts specific values, but stops at the point that the value changes.

    Assuming the sequence always starts with a "P"...

    Data Range
    A
    B
    1
    Sequence
    Count
    2
    P
    7
    3
    L
    4
    L
    5
    L
    6
    L
    7
    L
    8
    L
    9
    L
    10
    P
    5
    11
    L
    12
    L
    13
    L
    14
    L
    15
    L
    16
    P
    2
    17
    L
    18
    L
    19


    This array formula** entered in B2 and copied down as needed:

    =IF(A2="P",COUNTIF(A3:INDEX(A3:A$19,MATCH(TRUE,A3:A$19<>"L",0)),"L"),"")

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.

    Note how the formula refers to 1 cell beyond the last cell that contains data.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  3. #3
    Registered User
    Join Date
    09-29-2014
    Location
    New Zealand
    MS-Off Ver
    2010
    Posts
    14

    Re: Formula that counts specific values, but stops at the point that the value changes.

    Thanks, this worked perfectly!

  4. #4
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Formula that counts specific values, but stops at the point that the value changes.

    You're welcome. Thanks for the feedback!


    If your question has been solved please mark the thread as being solved.

    In the menu bar above the very first post select Thread Tools, then select Mark this thread as solved.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 2
    Last Post: 11-18-2014, 06:26 AM
  2. Formula that counts unique values within a criteria
    By GRACEROUHANA in forum Excel Formulas & Functions
    Replies: 14
    Last Post: 11-03-2013, 01:20 PM
  3. [SOLVED] MS Word - Macro that counts the number of "~" between two specific values
    By llfinney in forum Word Programming / VBA / Macros
    Replies: 4
    Last Post: 10-14-2013, 07:06 PM
  4. Averaging a specific range of values from a reference point
    By evydmb in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-05-2013, 10:56 AM
  5. Formula/function that counts amount of rows between specific number.
    By angelitovs in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-12-2012, 09:29 PM

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