+ Reply to Thread
Results 1 to 9 of 9

Count Consecutive Values

  1. #1
    Registered User
    Join Date
    10-06-2009
    Location
    Diemen, The Netherlands
    MS-Off Ver
    Excel 2007
    Posts
    87

    Count Consecutive Values

    Good morning everyone,

    I'm looking for a VBA code or formula that will count consecutive values in a column.
    Please look at my example sheet.


    Thank you,

    Roberto Lucesi, The Netherlands
    Last edited by roberto1111; 12-29-2009 at 03:08 AM.

  2. #2
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,375

    Re: Count Consecutive Values

    maybe like this

    =SUMPRODUCT(--(B6:B11=(B5:B10)+1))

  3. #3
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Count Consecutive Values

    Try this:
    Please Login or Register  to view this content.
    Does that help?
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  4. #4
    Registered User
    Join Date
    10-06-2009
    Location
    Diemen, The Netherlands
    MS-Off Ver
    Excel 2007
    Posts
    87

    Re: Count Consecutive Values

    Good day Teylyn and Ron,

    I must apologize, I made a wrong example here.
    The consecutive values al spread over a column, in stead of following up to one another.

    Please take a look at the right example I've just attached.


    Thank you for your time,

    Roberto Lucesi

  5. #5
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,375

    Re: Count Consecutive Values

    Hmm.. maybe with a helper column in Column C

    =SUMPRODUCT(--($B$9:$B$17=B9+1))

    copied down, and then in B7

    =SUM(C8:C17)

    The helper column can be hidden.

  6. #6
    Registered User
    Join Date
    10-06-2009
    Location
    Diemen, The Netherlands
    MS-Off Ver
    Excel 2007
    Posts
    87

    Re: Count Consecutive Values

    A helper column on the side would be a problem since there is'nt space on the actual sheet to do so, there's only space above the columns.

    Any ideas?

  7. #7
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,375

    Re: Count Consecutive Values

    You mean you've already used all available 16384 columns?? Why do I find it hard to believe that....?

    You could have the helper column on a separate sheet, say column A on Sheet2 and then change the formula to be

    =SUMPRODUCT(--(Sheet1!$B$9:Sheet1!$B$17=Sheet1!B9+1))

    and copy down, and then do in B7

    =SUM(Sheet2!A8:A17)

    adjust sheet names and ranges to suit.

    hth

  8. #8
    Valued Forum Contributor
    Join Date
    10-15-2007
    Location
    Home
    MS-Off Ver
    Office 2010, W10
    Posts
    373

    Re: Count Consecutive Values

    Hi

    Try:

    =SUM(0+(B9:B17-TRANSPOSE(B9:B17)=1))

    This is an array formula, you have to confirm it with CTRL+SHIFT+ENTER.

  9. #9
    Registered User
    Join Date
    10-06-2009
    Location
    Diemen, The Netherlands
    MS-Off Ver
    Excel 2007
    Posts
    87

    Talking Re: Count Consecutive Values

    Good day Lecxe,

    The arrayformula works perfectly! Thanks a lot for helping me out.

    Teylyn en Ron also thank you for your time.

+ 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