+ Reply to Thread
Results 1 to 6 of 6

Need to count max consecutive string of two values in a ROW

  1. #1
    Registered User
    Join Date
    01-10-2013
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    7

    Need to count max consecutive string of two values in a ROW

    Hello.

    I have a row such as this:

    Yes No Yes Yes Maybe Yes No No Yes Maybe No

    I need to count the longest consecutive string of both Yes & Maybe. So for my example the answer is 4 (Yes Yes Maybe Yes).


    Here is another example using letters:

    A B C B B A B C A A C A

    How would I get the max consecutive string of A & C. The answer in this example is 5 (C A A C A).

    Need the formula or array.

    Any help is greatly appreciated!

  2. #2
    Banned User!
    Join Date
    10-14-2006
    Posts
    1,211

    Re: Need to count max consecutive string of two values in a ROW

    =MAX(FREQUENCY(IF(A1:A12={"Yes","Maybe"},ROW(A1:A12)),IF(A1:A12="No",ROW(A1:A12))))

    Ctrl+Shift+Enter, not just Enter

  3. #3
    Registered User
    Join Date
    01-10-2013
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Need to count max consecutive string of two values in a ROW

    Thank you teethless mama. Seems to be working good. Thanks again.

  4. #4
    Registered User
    Join Date
    01-10-2013
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Need to count max consecutive string of two values in a ROW

    Okay, the formula is working when data runs up and down one column, however it is not working for a row. I tried changing the ROW in the formula (both of them) to COLUMN. I also made sure to change the range input to A1:L1. When I Ctrl+Shift+Enter the array, it gives me Error or Value prompt. Any ideas what's wrong?

  5. #5
    Registered User
    Join Date
    01-10-2013
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Need to count max consecutive string of two values in a ROW

    Anyone have a solution to this? I need it to count the length of a streak that includes two different values in a ROW (not a COLUMN). See opening post for examples.

  6. #6
    Banned User!
    Join Date
    10-14-2006
    Posts
    1,211

    Re: Need to count max consecutive string of two values in a ROW

    Try this:

    =MAX(FREQUENCY(IF(A1:K1={"Yes";"Maybe"},COLUMN(A1:K1)),IF(A1:K1="No",COLUMN(A1:K1))))

    Ctrl+Shift+Enter, not just Enter

+ 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