+ Reply to Thread
Results 1 to 9 of 9

Count how many times a value occurs IN A ROW [consecutively]

  1. #1
    Registered User
    Join Date
    07-17-2019
    Location
    Sweden
    MS-Off Ver
    Version 1906 MS Excel
    Posts
    34

    Count how many times a value occurs IN A ROW [consecutively]

    I want to count the maximum amount when a specific number occurs in a row, is there any possibility of doing this? So for example, if I have a column that contains 1 0 0 0 0 1 0 0 1 I want to return a 4 because that is the maximum amount that the number zero appears in a row!

  2. #2
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,064

    Re: Count how many times a value occurs IN A ROW [consecutively]

    With your data in a1:I1

    =MAX(FREQUENCY(IF(A1:I1=0,COLUMN(A1:I1)),IF(A1:I1<>0,COLUMN(A1:I1))))
    Array formula, use Ctrl-Shift-Enter
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

  3. #3
    Registered User
    Join Date
    07-17-2019
    Location
    Sweden
    MS-Off Ver
    Version 1906 MS Excel
    Posts
    34

    Re: Count how many times a value occurs IN A ROW [consecutively]

    Thank you! I can't get it to work though... does your formula assume that the only values in the column are 0 and 1? Because there are Three different values, 0, 1 and 3. I'm not very familiar with Array formula so if you could explain your formula a bit it would be very appriciated.
    Thank you in advance

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,969

    Re: Count how many times a value occurs IN A ROW [consecutively]

    Did you enter it correctly with CTRL+SHIFT+ENTER.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  5. #5
    Registered User
    Join Date
    07-17-2019
    Location
    Sweden
    MS-Off Ver
    Version 1906 MS Excel
    Posts
    34

    Re: Count how many times a value occurs IN A ROW [consecutively]

    Yes I did, I get a value of 254 when the correct one is 96.

  6. #6
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,063

    Re: Count how many times a value occurs IN A ROW [consecutively]

    It should work OK. So, please post a sample sheet.

    Unfortunately the attachment icon doesn't work at the moment. So, to attach an Excel file you have to do the following: Just before posting, scroll down to Go Advanced and then scroll down to Manage Attachments. Now follow the instructions at the top of that screen.
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  7. #7
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,064

    Re: Count how many times a value occurs IN A ROW [consecutively]

    Quote Originally Posted by helloxxx View Post
    Thank you! I can't get it to work though... does your formula assume that the only values in the column are 0 and 1? Because there are Three different values, 0, 1 and 3.
    Well, that's the data you supplied - a list of zeros and ones.
    No mention there are three values.
    If there are three values, it would have been helpful to have stated that in your initial description of the problem.

    This shouldn't affect it though.

    If you put the values as

    1 0 0 0 0 3 0 0 1

    That's three values 0 1 and 3
    It still returns 4 which is correct.

    As stated above upload a file with the exact data.

  8. #8
    Registered User
    Join Date
    07-17-2019
    Location
    Sweden
    MS-Off Ver
    Version 1906 MS Excel
    Posts
    34

    Re: Count how many times a value occurs IN A ROW [consecutively]

    Sorry my bad, I did a mistake but now it works. Thank you so much!

  9. #9
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,969

    Re: Count how many times a value occurs IN A ROW [consecutively]

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

+ 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. Determining how many times a number occurs consecutively
    By happyladyfromca in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-06-2018, 01:05 PM
  2. Replies: 10
    Last Post: 10-09-2014, 08:06 PM
  3. [SOLVED] Count the number of times an A appears 5 or more times consecutively
    By CCook310 in forum Excel Formulas & Functions
    Replies: 17
    Last Post: 10-02-2013, 04:02 PM
  4. Count number a times a specific value appears consecutively.
    By kww0027 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-03-2013, 06:17 PM
  5. Counting how many times something occurs consecutively
    By hockeyadc in forum Excel Formulas & Functions
    Replies: 19
    Last Post: 11-18-2012, 09:13 PM
  6. Count how many times a letter occurs
    By GreenMartian in forum Excel General
    Replies: 2
    Last Post: 03-15-2009, 04:30 AM
  7. I would like to count the # of times a value occurs in Col B base
    By shopaholic in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-09-2005, 12:30 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