+ Reply to Thread
Results 1 to 13 of 13

Looking for a formula to count the number of times a specific value appears in sequence in

  1. #1
    Registered User
    Join Date
    05-10-2019
    Location
    New Zealand
    MS-Off Ver
    2016
    Posts
    31

    Looking for a formula to count the number of times a specific value appears in sequence in

    Hello Community
    I would like to request some help for the following
    I am looking for a formula that will give a total for the number of times a specific value appears in sequence in a column
    My spreadsheet that I need this for is several hundred rows long, so have included a sample. Column A is the data to work with,The correct answers are manually entered in Columns B and C
    Hope this makes sense
    Thank you in advance
    Cheers
    Brian
    Attached Files Attached Files

  2. #2
    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. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,417

    Re: Looking for a formula to count the number of times a specific value appears in sequenc

    In B2 copied across and down:

    =IF(AND($A2=B$1,$A3<>$A2),COUNTIF($A$2:A2,B$1)-SUM(B$1:B1),"")
    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.

  3. #3
    Registered User
    Join Date
    05-10-2019
    Location
    New Zealand
    MS-Off Ver
    2016
    Posts
    31

    Re: Looking for a formula to count the number of times a specific value appears in sequenc

    Hi Ali
    Wow, Works a treat, still trying to work out how it works!
    Thanks so much for taking the time to help me
    Regards
    Brian

  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. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,417

    Re: Looking for a formula to count the number of times a specific value appears in sequenc

    Let me know if you want me to explain it.

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

    Also, as a relatively new member of the forum, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.

  5. #5
    Registered User
    Join Date
    05-10-2019
    Location
    New Zealand
    MS-Off Ver
    2016
    Posts
    31

    Re: Looking for a formula to count the number of times a specific value appears in sequenc

    Thanks for the pointers above
    Apologies for posting this as a new thread (I thought I had marked this as solved)
    I want to count the number of times "Column B" has a value, while ignoring the values in "Column C" , A value in "Column A" is what halts the sequence. AliGW was good enough to write the formula in yellow for me for a totally different application . I have been trying to get it to work here with helper rows etc , but Im stuck
    Answers Im after are in "Column E"
    --Thanks in anticipation
    Attached Files Attached Files

  6. #6
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,213

    Re: Looking for a formula to count the number of times a specific value appears in sequenc

    Not sure why you ignore B2
    Maybe try at E2

    =IF((SUMPRODUCT(--(MOD(SUMPRODUCT((B$2:B2=1)*(B$3:B3="")),{99,2})<>{1,0}))=2)*(B2=1)*(B3=""),SUM(B$2:B2)-SUM(E$1:E1)-D$1,"")
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    05-10-2019
    Location
    New Zealand
    MS-Off Ver
    2016
    Posts
    31

    Re: Looking for a formula to count the number of times a specific value appears in sequenc

    Hi Bo_Ry
    Thanks for looking at this, Ill try to explain what Im after another way- hope this helps explain what Im after
    I want to count the number of times the "1" occurs in "Column B", until a "1" appears in "Column A"
    Ive added a bit more data and changed some of the inputs--answers Im after are in "Column F"
    (Dont assume Ive copied your formula correctly down--array formulas are something Im not comfortable with---yet)
    Thanks in advance
    Cheers
    Brian
    Attached Files Attached Files

  8. #8
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,481

    Re: Looking for a formula to count the number of times a specific value appears in sequenc

    I mark the last row+1 with 1 as ending sign.
    Try this array formua in E2:
    Please Login or Register  to view this content.
    **Array formulas are not entered in the same way as 'standard' formulas. Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. If you've done it correctly, you'll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself).
    Attached Files Attached Files
    Quang PT

  9. #9
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,213

    Re: Looking for a formula to count the number of times a specific value appears in sequenc

    Please try at E2

    =IF((A2="")*(A3=1)+(COUNT(A3:C42)=0),IFNA(SUM(INDEX(B$1:B2,MATCH(2,A$1:A2)):B2),""),"")
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    05-10-2019
    Location
    New Zealand
    MS-Off Ver
    2016
    Posts
    31

    Re: Looking for a formula to count the number of times a specific value appears in sequenc

    Thank you for your formula, works well

  11. #11
    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. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,417

    Re: Looking for a formula to count the number of times a specific value appears in sequenc

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  12. #12
    Registered User
    Join Date
    05-10-2019
    Location
    New Zealand
    MS-Off Ver
    2016
    Posts
    31

    Re: Looking for a formula to count the number of times a specific value appears in sequenc

    Thanks bebo021999
    Your formula works well

  13. #13
    Registered User
    Join Date
    05-10-2019
    Location
    New Zealand
    MS-Off Ver
    2016
    Posts
    31

    Re: Looking for a formula to count the number of times a specific value appears in sequenc

    Thanks Bo_Ry
    This also works well
    If you get a chance can you explain how the count A3:C42 works and why it is that size to start with?
    Also why does the INDEX and MATCH start in B$1 & A$1 ?
    Regards
    brian

+ 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 number of times a specific text appears for a certain date
    By Alfie092 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-10-2020, 12:25 PM
  2. Count number of times a specific word appears
    By csepesy in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-07-2017, 09:48 PM
  3. How do i count the number of times a sequence appears in a row of data
    By dony85 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-02-2014, 01:57 PM
  4. count the number of times a number appears in a specific range
    By myjebay1 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-18-2013, 11:01 AM
  5. Count number a times a specific value appears consecutively.
    By kww0027 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-03-2013, 06:17 PM
  6. Replies: 5
    Last Post: 11-22-2010, 06:31 PM
  7. [SOLVED] count the number of times a specific word appears in a column
    By BAR in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 06-27-2006, 12:10 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