+ Reply to Thread
Results 1 to 8 of 8

Formula for counting cells consecutively

  1. #1
    Registered User
    Join Date
    05-01-2012
    Location
    Prestwick
    MS-Off Ver
    Excel 2010
    Posts
    4

    Formula for counting cells consecutively

    First of all, hello - I have found these forums to be invaluable over the years and have always found any answers in previous posts, but not this time......

    So if anyone could help me with the following I would be ever so grateful.

    My problem is that I want my destination cell to show the maximum number of times 'X' appears consecutively in a single row so that the answers in the attached worksheet would show:

    M2 = 3
    M3 = 8
    M4 = 2
    M5 = 12

    Xinarow.xlsx

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,612

    Re: Formula for counting cells consecutively

    Use the COUNTIF function
    Ben Van Johnson

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

    Re: Formula for counting cells consecutively

    This seems to work, but I don't have a clue how

    Array Formula
    =MAX(FREQUENCY(IF(ISNUMBER(MATCH(A2:L2,{"","x"},0 )),COLUMN(A2:L2)),IF(ISNA(MATCH(A2:L2,{"","x"},0) ),IF(A2:L2<>"",COLUMN(A2:L2)))))

    Source: http://www.excelbanter.com/showthread.php?t=260780
    See T Valko's post
    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.

  4. #4
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Formula for counting cells consecutively

    I don't think that works for the sample shown, though, Special-K, e.g. that give 8 for row 2 not 3 as required

    You can use a simpler version for this, i.e.

    =MAX(FREQUENCY(IF(A2:L2="x",COLUMN(A2:L2)),IF(A2:L2<>"x",COLUMN(A2:L2))))

    confirmed with CTRL+SHIFT+ENTER
    Audere est facere

  5. #5
    Registered User
    Join Date
    05-01-2012
    Location
    Prestwick
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Formula for counting cells consecutively

    Firstly, my thanks Special-K for you quick endeavours, but daddylonglegs has got what I needed - this is one headache I needn't worry about now.

    THANKYOU!!

  6. #6
    Registered User
    Join Date
    05-01-2012
    Location
    Prestwick
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Formula for counting cells consecutively

    Actually, perhaps my headache continues..... it seems that I need to find out the maximum times it appears in a row over consecutive rows, i.e. where the next row of data is seen as a continuation.

    I have attached a worksheet which should make it a little clearer - I have put in the array formula (from daddylonglegs) for the first line of data as this still works, but can't fathom how to alter it to suit, so that the answer for B2 to A3 should be 5.

    Thanks again for any help/patience!

    wsheet1.xlsx

  7. #7
    Registered User
    Join Date
    05-01-2012
    Location
    Prestwick
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Formula for counting cells consecutively

    Still haven't managed to work it out yet.....

    Save me from this despair!

  8. #8
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Formula for counting cells consecutively

    hi-please see forum rule 8

    8. Don't cross-post without a link. Cross-posting is when you post the same question in other forums on the web. You'll find people are disinclined to respond to cross-posts because they may be wasting their time solving a problem that has been solved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser) to the cross-post. Expect cross-posts without a link to be closed.

    please add links here to your cross-posts in any other forums. thanks :-)
    Josie

    if at first you don't succeed try doing it the way your wife told you to

+ 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