+ Reply to Thread
Results 1 to 8 of 8

Counting Consecutive entries

  1. #1
    Registered User
    Join Date
    02-23-2014
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    9

    Counting Consecutive entries

    Hi
    I am creating a spreadsheet for health promotion for my clients
    I want to track consecutive days without various habits eg. smoking
    I have a column where the client enters the number of cigarettes smoked and I want another column to show consecutive days without smoking
    I am currently using this formula
    =MAX(FREQUENCY(IF($Z$7:$Z$70="Zero",ROW($Z$7:$Z$70)),IF($Z$7:$Z$70<>"Zero",ROW($Z$7:$Z$70))))

    the problem is that it changes the result in previous rows
    eg. if client smoked on 1st, 2nd, 3rd then didn't smoke on 4th and 5th - when they enter Zero on the 5th it changes the result to "2" on all the rows including 1st, 2nd, 3rd which should say 0

    if someone could help me correct this I would appreciate it
    I am self taught on spreadsheets over the internet so I am definitely an amateur!
    Attached Files Attached Files
    Last edited by AlexAgain; 02-24-2014 at 12:22 AM. Reason: add spreadsheet file

  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 entries

    Attach a sample workbook. Make sure there is just enough data to make it clear what is needed. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are demonstrated, mock them up manually if needed. Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic
    "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
    02-23-2014
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Counting Consecutive entries

    ok thanks
    I attached the part of the spreadsheet I am talking about

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,923

    Re: Counting Consecutive entries

    Nothing seems to be changing here if I alter values in the AA column, so I'm a bit confused.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  5. #5
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Counting Consecutive entries

    What are results you wish to see? If it is running total:
    =IF(ISNUMBER(AA27),0,AB26+1)
    • Please remember to mark threads Solved with Thread Tools link at top of page.
    • Please use code tags when posting code: [code]Place your code here[/code]
    • Please read Forum Rules

  6. #6
    Registered User
    Join Date
    02-23-2014
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Counting Consecutive entries

    so the result I want is
    for Feb 1,2,3 or any day there is a value other than zero in the 2nd column the result in the 3rd column should be 0
    I want the result to be the consecutive days without smoking

    I think when I pasted the chart in a new sheet to attach it here it got the columns wrong

    the formula I am using is counting consecutive "Zero" results but when I add a new value it changes all the past results as well. I just want it to change that day's results

  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 entries

    been away for a few days
    maybe in k2
    =IF(j2="zero",k1+1,0)

  8. #8
    Registered User
    Join Date
    02-23-2014
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Counting Consecutive entries

    amazing thanks! and so much simpler than all the things I tried

+ 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. Consecutive Counting - Please Help
    By dmiz002 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-31-2012, 05:28 AM
  2. Counting consecutive 0's
    By bhenderson in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 11-09-2011, 07:25 PM
  3. Formula to recognize consecutive entries
    By Laura2018 in forum Excel General
    Replies: 3
    Last Post: 07-02-2009, 08:24 PM
  4. Prevent Consecutive Entries
    By JorgeAE in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-28-2006, 12:00 PM
  5. Adding Consecutive Entries
    By FLKULCHAR in forum Excel General
    Replies: 1
    Last Post: 06-03-2005, 11:48 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