+ Reply to Thread
Results 1 to 10 of 10

How would you count (& denote) consecutive values in a column?

  1. #1
    Registered User
    Join Date
    08-16-2012
    Location
    london
    MS-Off Ver
    Excel 2010
    Posts
    22

    How would you count (& denote) consecutive values in a column?

    Hi all,

    Please, kindly open the file attachment and see if you can do this -
    I have a column of +1 and -1 values (in A:A). I want the opposite column (B:B) to reproduce the value in the A:A column if only in the previous 2 cells, there have been 2 consecutive -1 values from A.

    If you could also write the formula to show how many instances of "2 consecutive -1 values" are in A:A, I would be so grateful.

    Thank you for your time
    NOTE :
    Sometimes, there are times when there have are more than two -1 values in the previous. I want to ONLY reproduce vales when there have been 2 consecutive -1 values NOT >2. What can I do?
    Attached Files Attached Files
    Last edited by schill2; 11-23-2013 at 05:02 PM.

  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
    53,048

    Re: How would you count (& denote) consecutive values in a column?

    Maybe this in B3, copied down?
    =IF(AND(A2<0,A1<0),A3,"")

    and then...
    =COUNT(B3:B600)
    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 RobertMika's Avatar
    Join Date
    06-22-2009
    Location
    Haverhill, UK
    MS-Off Ver
    Excel 2003-13
    Posts
    1,530

    Re: How would you count (& denote) consecutive values in a column?

    For -1 and 2 consecutive
    =SUM(IF(FREQUENCY(IF(A1:A100=-1,ROW(A1:A100)),IF(A1:A100<>-1,ROW(A1:A100)))=2,1))
    For 2 and more
    =SUM(IF(FREQUENCY(IF(A1:A100=-1,ROW(A1:A100)),IF(A1:A100<>-1,ROW(A1:A100)))=>2,1))
    Confirm COntrol+Shift+enter
    If you are http://www.excelforum.com/image.php?type=sigpic&userid=125481&dateline=1392355029happy with the results, please add to the contributor's
    reputation by clicking the reputation icon (star icon).




    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.
    To undo, select Thread Tools-> Mark thread as Unsolved.
    http://www.excelaris.co.uk

  4. #4
    Registered User
    Join Date
    08-16-2012
    Location
    london
    MS-Off Ver
    Excel 2010
    Posts
    22

    Re: How would you count (& denote) consecutive values in a column?

    [QUOTE=FDibbins;3486924]Maybe this in B3, copied down?
    =IF(AND(A2<0,A1<0),A3,"")

    Sometimes, there are times when there have are more than two -1 values in the previous. I want to ONLY reproduce vales when there have been 2 consecutive -1 values NOT >2. What can I do?

  5. #5
    Registered User
    Join Date
    08-16-2012
    Location
    london
    MS-Off Ver
    Excel 2010
    Posts
    22

    Re: How would you count (& denote) consecutive values in a column?

    Hi Robert, can you also answer my first question?
    Last edited by schill2; 11-23-2013 at 05:03 PM.

  6. #6
    Forum Expert RobertMika's Avatar
    Join Date
    06-22-2009
    Location
    Haverhill, UK
    MS-Off Ver
    Excel 2003-13
    Posts
    1,530

    Re: How would you count (& denote) consecutive values in a column?

    Check the file
    Copy of consec2.xlsx

  7. #7
    Registered User
    Join Date
    08-16-2012
    Location
    london
    MS-Off Ver
    Excel 2010
    Posts
    22

    Re: How would you count (& denote) consecutive values in a column?

    Thanks Robert, what about the first question? (See FDibbins's answer and my reply)

  8. #8
    Forum Expert RobertMika's Avatar
    Join Date
    06-22-2009
    Location
    Haverhill, UK
    MS-Off Ver
    Excel 2003-13
    Posts
    1,530

    Re: How would you count (& denote) consecutive values in a column?

    Do you need to retrieve all -1?
    Or all -1 where the consec. is 2?
    So let say if the answer is 4 you got 8 -1?

  9. #9
    Registered User
    Join Date
    08-16-2012
    Location
    london
    MS-Off Ver
    Excel 2010
    Posts
    22

    Re: How would you count (& denote) consecutive values in a column?

    Say we had this in A:A:
    1
    -1 (this value does not gets reproduced into B:B because there have not been 2 consecutive -1 values)
    -1 (this value does not gets reproduced into B:B because there have not been 2 consecutive -1 values)
    -1 (this value gets reproduced because into B:B there have been 2 consecutive -1 values)
    1 (this value does not gets reproduced into B:B because there have been 3 consecutive -1 values instead of 2)

    that is what i am trying to do with excel

  10. #10
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: How would you count (& denote) consecutive values in a column?

    I think that this might work for you

    Part 1 - Enter in B3 and copy down the length of your data.

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Part 2

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    <---------If you like someone's answer, click the star to the left of one of their posts to give them a reputation point for that answer.
    Ron W

+ 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. Count of consecutive values in a row
    By Bruno Silva in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 04-12-2013, 09:19 AM
  2. Count consecutive values
    By tbelanger007 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-14-2013, 03:39 PM
  3. Count Consecutive Values
    By roberto1111 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 02-05-2010, 05:33 AM
  4. [SOLVED] Count Intervals of 2 Consecutive Values in same Row and Return Count across Row
    By Sam via OfficeKB.com in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 11-29-2005, 11:30 AM
  5. [SOLVED] How do I denote values stored in columns in my macro?
    By Greg in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-08-2005, 03:05 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