+ Reply to Thread
Results 1 to 6 of 6

Counting sequences

  1. #1
    Registered User
    Join Date
    10-08-2012
    Location
    Zurich
    MS-Off Ver
    Excel 2010
    Posts
    9

    Counting sequences

    Hi all

    You may advice how to solve the following question:

    I have several columns that contain sequences of numbers (marks). These numbers consist of 1, 2 and 3; each sequence always starts with 1, whereas the rest is not fixed. In between sequences there can occasionally occur 0, but not necessarily.
    I now would want to have for each of this column an additional column that counts these numbers as follows: each sequence (always starting with 1) should be counted as one `trial` continuously.

    I attached an example with an INPUT and an OUTPUT file. This illustrated how the results should look like.

    Many thanks in advance,
    Lisa
    Attached Files Attached Files

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,946

    Re: Counting sequences

    HI, I dont see your logic there

    Could you explain how you arrive at your answers?
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: Counting sequences

    Hi

    C2: =IF(A2=1,1,0)
    D2: =IF(B2=1,1,0)
    C3: =IF(A3=0,0,IF(AND(A3=1,A3<>A2),MAX($C$2:C2)+1,C2))
    D3: =IF(B3=0,0,IF(AND(B3=1,B3<>B2),MAX($D$2:D2)+1,D2))

    Copy from C3:C3 down as required.

    HTH

    rylo

  4. #4
    Valued Forum Contributor
    Join Date
    03-29-2013
    Location
    United Kingdom
    MS-Off Ver
    Office/Excel 2013
    Posts
    1,749

    Re: Counting sequences

    Example_Trial.xlsx

    Here you go.. Columns E:F calculate the series number using:-
    =IF(A2=0,0,IF(AND(A2=1,A1<>1),1+MAX(OFFSET(E$1,1,0,COUNT($A1:$A$2))),E1))

    @FDibbins The way i see it. column C numbers each new col a series sequentially.. D does same for col b
    Last edited by AndyLitch; 04-11-2013 at 01:02 AM.
    Elegant Simplicity............. Not Always

  5. #5
    Registered User
    Join Date
    10-08-2012
    Location
    Zurich
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Counting sequences

    Many thanks for all the SUPER-FAST replays! -)

    thank you very much!
    lisa

  6. #6
    Valued Forum Contributor
    Join Date
    03-29-2013
    Location
    United Kingdom
    MS-Off Ver
    Office/Excel 2013
    Posts
    1,749

    Re: Counting sequences

    You're welcome..
    Check it's what you're looking for and if so, could you please close (Mark) this thread as solved? Go in to the top right-hand side of this page, choose "Thread Tools" from the menu, then select "solved" from the drop down menu.

    And if you're happy with my work please select the * bottom left.

+ 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