+ Reply to Thread
Results 1 to 8 of 8

re: counting consecutive numbers

  1. #1
    Registered User
    Join Date
    09-10-2013
    Location
    toronto, ontario
    MS-Off Ver
    Excel 2007
    Posts
    4

    re: counting consecutive numbers

    Hello all!. I need to count consecutive numbers, but with a condition.

    i suppose this would be done in one or two steps, the example spreadsheet is attached.

    I have two columns.
    one for temperature M26:M43826, the other is relative humidity N26:N43826.

    Part1

    What i want to do is,
    for every value that is >=5 and <40 for M26:M43826 AND >=80 in column N26:N43826
    should be designated a value 1 in cells Q26:Q43826

    if either of those two criteria are not met, then a value of 0 should be assigned in Q26:Q43826

    Part2

    ask excel to count the number of maximum consecutive cells in Q26:Q43826 and insert into P:15.

    I'll use a small section of the dataset to use as an example
    lets say in the column Q27-Q34 we get the following values:. In P:15, the value should be 3
    0
    1
    1
    1
    0
    0
    1
    0

    thanks for the help
    -Bismo
    Attached Files Attached Files
    Last edited by bismo; 09-10-2013 at 12:50 PM.

  2. #2
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: counting consecutive numbers

    O26 =--AND(M26>=5,M26<40,N26>=80) fill down ,now if you dont want your workbook to grind to a halt
    copy column 0 paste back over itself special values to remove formulas!
    then in p15
    =MAX( FREQUENCY( IF( O26:O43826=1, ROW(O26:O43826) ), IF(O26:O43826<>1, ROW(O26:O43826) ) ) ) array entered
    this gives 3 for the example given
    ie rows
    3543
    3544
    3545
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  3. #3
    Registered User
    Join Date
    09-10-2013
    Location
    toronto, ontario
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: counting consecutive numbers

    step one works great!
    but step two returns an error when i input the forumula into the box.

    yes it will be slow, but unfortunately I cannot delete the original forumula, as it needs to be retained for the futre
    -bismo

  4. #4
    Registered User
    Join Date
    09-10-2013
    Location
    toronto, ontario
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: counting consecutive numbers

    accidental double post

  5. #5
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: counting consecutive numbers

    works fine for me did you array enter it? with ctrl+shift+enter attached is a shorter sample
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    09-10-2013
    Location
    toronto, ontario
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: counting consecutive numbers

    Quote Originally Posted by martindwilson View Post
    works fine for me did you array enter it? with ctrl+shift+enter attached is a shorter sample
    yes i did the array. (Ctrl D) i arrayed all 44000 or so cells.
    this part works. it is part two that is the issue

    when i opened your document. it seems to work okay using only 10 cells. when i altered the cell numbers to include the whole range (copied your forumula and pasted into my orginal document) and pasted into mine.

    error. "the value in this formula is of the wrong datatype"
    =MAX( FREQUENCY( IF( Q26:Q43826=1, ROW(Q26:Q43826) ), IF(Q26:Q43826<>1, ROW(Q26:Q43826) ) ) )


    I would give you my original document, but the filesize is larger than 1mb allowance.
    I am at a loss
    Last edited by bismo; 09-10-2013 at 03:05 PM.

  7. #7
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: counting consecutive numbers

    here is the full version
    you only array enter
    =MAX( FREQUENCY( IF( Q26:Q43826=1, ROW(Q26:Q43826) ), IF(Q26:Q43826<>1, ROW(Q26:Q43826) ) ) ) with ctrl+shift+enter
    so it looks like this in the formula bar

    {=MAX( FREQUENCY( IF( Q26:Q43826=1, ROW(Q26:Q43826) ), IF(Q26:Q43826<>1, ROW(Q26:Q43826) ) ) )}
    notice the curly brackets that appear when array entered
    Attached Files Attached Files
    Last edited by martindwilson; 09-10-2013 at 03:43 PM.

  8. #8
    Registered User
    Join Date
    09-10-2013
    Location
    toronto, ontario
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: counting consecutive numbers

    you have to be more descriptive of what you mean by "you only array enter"
    we are only talking about 1 cell. i don't understand the problem
    this column is actually 1 of 200 if i can't copy and paste this forumula, i cant use it.

    please tell me why this insn't working.

  9. #9
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: counting consecutive numbers

    you said you want the result in p15 there is only one formula that counts the consecutive ones where are you going to copy paste it to? i dont think the workbook would take 20 columns set up like that
    see here about array formulas
    http://office.microsoft.com/en-us/ex...001087290.aspx
    =--AND(M26>=5,M26<40,N26>=80) is not an array formula you simply copied it down using autofil

+ 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. Counting consecutive numbers in excel
    By kurtvon in forum Excel General
    Replies: 3
    Last Post: 05-02-2016, 03:38 PM
  2. Replies: 6
    Last Post: 11-13-2012, 07:33 AM
  3. Replies: 5
    Last Post: 07-26-2012, 08:46 PM
  4. Replies: 6
    Last Post: 03-23-2012, 06:03 PM
  5. counting only consecutive numbers over 11
    By sgk18 in forum Excel General
    Replies: 5
    Last Post: 01-30-2012, 05:16 AM

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