+ Reply to Thread
Results 1 to 24 of 24

Find consecutive strings of numbers from out of order list, and calculate longest string

  1. #1
    Forum Contributor
    Join Date
    03-30-2020
    Location
    Wales, UK
    MS-Off Ver
    365 (Mac)
    Posts
    191

    Find consecutive strings of numbers from out of order list, and calculate longest string

    Hi I am trying to find a solution to problem I want to solve on my parkrun results spreadsheet. The definition of the calculation I need to make is: 'The total streak of finish positions, but starting anywhere, in any order. e.g. If you have finished: 123, 120, 304, 122, 201, 121 It would be 4, since you have: 120,121,122 and 123.

    I have just manually checked my 'floating finish position' it is 24 - If anyone might be able to find a way to achieve this in an Excel formula, I would be really grateful. I have tried and failed!

    Thanks!

  2. #2
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,448

    Re: Find consecutive strings of numbers from out of order list, and calculate longest stri

    Administrative note

    Welcome to the forum

    in your haste to solve your problem, you probably missed the yellow banner advising how to get answers faster by posting a sheet ?

    Please take a moment to read it and attach a sheet accordingly.

    Thanks you for helping us help you

  3. #3
    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,869

    Re: Find consecutive strings of numbers from out of order list, and calculate longest stri

    Please attach a sample workbook - details at the top of the page.
    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.

  4. #4
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,448

    Re: Find consecutive strings of numbers from out of order list, and calculate longest stri

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however it has been brought to our attention that the same query has been posted on one or more other forums and you have not provided the required cross-post link(s) here.

    Please see Forum Rule #3 about cross-posting and adjust accordingly. Read this to understand why we (and other sites like us) consider this to be important.

    I wll add them for you

    https://www.reddit.com/r/excel/comme...s_from_out_of/

    https://www.mrexcel.com/board/thread...ngest.1129571/

  5. #5
    Forum Contributor
    Join Date
    03-30-2020
    Location
    Wales, UK
    MS-Off Ver
    365 (Mac)
    Posts
    191

    Re: Find consecutive strings of numbers from out of order list, and calculate longest stri

    Hi. I have uploaded a file, but when I try to attach it is just blank.
    Attached Files Attached Files

  6. #6
    Forum Contributor
    Join Date
    03-30-2020
    Location
    Wales, UK
    MS-Off Ver
    365 (Mac)
    Posts
    191

    Re: Find consecutive strings of numbers from out of order list, and calculate longest stri

    Apologies, I was about to post those, as the other website pointed it out. Thanks.

  7. #7
    Forum Contributor
    Join Date
    03-30-2020
    Location
    Wales, UK
    MS-Off Ver
    365 (Mac)
    Posts
    191

    Re: Find consecutive strings of numbers from out of order list, and calculate longest stri

    Screenshot 2020-04-03 at 15.14.45.png

    I get this when trying to attach.

  8. #8
    Forum Contributor
    Join Date
    03-30-2020
    Location
    Wales, UK
    MS-Off Ver
    365 (Mac)
    Posts
    191

    Re: Find consecutive strings of numbers from out of order list, and calculate longest stri

    It now seems to have attached anyway 🤷🏻*♂️ It's the file called 'Example'.

  9. #9
    Forum Contributor
    Join Date
    03-30-2020
    Location
    Wales, UK
    MS-Off Ver
    365 (Mac)
    Posts
    191

    Re: Find consecutive strings of numbers from out of order list, and calculate longest stri

    Someone else suggested as per below, which will likely work and is great, but would really like to try and achieve it without extra columns or vbA, if at all possible

    If your finishing positions are all in one column you will need a couple of helper columns to facilitate the calculation. Firstly you want a column of unique finishing positions sorted in ascending order. Assuming your finish positions are in column A, in Google Sheets, I'd use =SORT(UNIQUE(A1:A999)) and I'm sure Excel will have some similar functions.
    Now you have your finish positions in column A and a sorted list of unique finish positions in, say, column B.
    In column C we'll want to make a column that checks if the number in the column to the left is consecutive or not, so put a "0" in C1 because we know that's the start of a consecutive run, then in C2 the formula =IF(B2-B1=1,C1+1,0) will check if the next number down is consecutive; if it is it adds 1 to the run so it counts up and if it's not it'll put a zero to indicate the start of a new run. Then just drag that formula down for however many rows you need.
    Finally, find the highest number in column C and add 1 using =MAX(C1:C999)+1

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

    Re: Find consecutive strings of numbers from out of order list, and calculate longest stri

    Please try

    =MAX(FREQUENCY(SORT(UNIQUE('All Completed Runs'!F3:F228)),IF(ISNA(MATCH(SEQUENCE(MAX('All Completed Runs'!F3:F228)),'All Completed Runs'!F3:F228,)),SEQUENCE(MAX('All Completed Runs'!F3:F228)))))
    Attached Files Attached Files

  11. #11
    Forum Contributor
    Join Date
    03-30-2020
    Location
    Wales, UK
    MS-Off Ver
    365 (Mac)
    Posts
    191
    Thanks. Will give that a try and get back to you. Thanks very much
    Last edited by AliGW; 04-04-2020 at 02:37 AM. Reason: Please don’t quote unnecessarily.

  12. #12
    Forum Contributor
    Join Date
    03-30-2020
    Location
    Wales, UK
    MS-Off Ver
    365 (Mac)
    Posts
    191

    Re: Find consecutive strings of numbers from out of order list, and calculate longest stri

    Wow, that worked perfectly. Thanks so much! One more thing, might you also be able to get the separate 'All Completed Runs - FFP-I' worksheet working as well? Thanks again, so much!

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

    Re: Find consecutive strings of numbers from out of order list, and calculate longest stri

    ์Not sure if this what you want, if not please provide manual expected result in the sheet.

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


    B3
    =INDEX('All Completed Runs'!$C$3:$E$228,MATCH(A3#,'All Completed Runs'!F3:F228,),{1,3})
    Attached Files Attached Files

  14. #14
    Forum Contributor
    Join Date
    03-30-2020
    Location
    Wales, UK
    MS-Off Ver
    365 (Mac)
    Posts
    191

    Re: Find consecutive strings of numbers from out of order list, and calculate longest stri

    Hi. This is almost there. The only thing I would like to change is to have all of my finishing positions listed in column A and then in Column B all of the corresponding first venues at which this was achieved and in C all of the corresponding dates on which they were achieved - but only for the ones that are part of a streak.

    Therefore, there should be a list in Column A of all of my unique finishing positions, going from 7 (my highest finishing position) down to 404 (my lowest finishing position) and then in B and C the corresponding first venues and dates on which these were achieved - only for finishing positions that are part of a streak. This will then result in a comprehensive list of all the position streaks I have done. Thanks so much.

    I have attached a new example with this in a manual format, in the 'Manual' worksheet.
    Attached Files Attached Files

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

    Re: Find consecutive strings of numbers from out of order list, and calculate longest stri

    Please change A3 to

    =SORT(UNIQUE('All Completed Runs'!F3:F228))

    B3
    =IF((A3+1=A4)+(A3-1=A2),IF(A3-1<>A2,INDEX('All Completed Runs'!$C$3:$E$228,MATCH(A3,'All Completed Runs'!$F$5:$F$230,),{1,3}),B2:C2),"")
    Attached Files Attached Files
    Last edited by Bo_Ry; 04-04-2020 at 12:56 PM.

  16. #16
    Forum Contributor
    Join Date
    03-30-2020
    Location
    Wales, UK
    MS-Off Ver
    365 (Mac)
    Posts
    191

    Re: Find consecutive strings of numbers from out of order list, and calculate longest stri

    That is absolutely brilliant. Thank you so much, it is now perfect!!

  17. #17
    Forum Contributor
    Join Date
    03-30-2020
    Location
    Wales, UK
    MS-Off Ver
    365 (Mac)
    Posts
    191

    Re: Find consecutive strings of numbers from out of order list, and calculate longest stri

    Hi again. When putting this into my full document, I have a spill error. I have put in those two formulas, but getting a spill error. Perhaps something to do with the blank cells?

  18. #18
    Forum Contributor
    Join Date
    03-30-2020
    Location
    Wales, UK
    MS-Off Ver
    365 (Mac)
    Posts
    191

    Re: Find consecutive strings of numbers from out of order list, and calculate longest stri

    I have now resolved this. Thanks again.

  19. #19
    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,869

    Re: Find consecutive strings of numbers from out of order list, and calculate longest stri

    Please share how you resolved it, for the benefit of all, and then mark the thread as solved.

  20. #20
    Forum Contributor
    Join Date
    03-30-2020
    Location
    Wales, UK
    MS-Off Ver
    365 (Mac)
    Posts
    191

    Re: Find consecutive strings of numbers from out of order list, and calculate longest stri

    I hadn’t filled down the formula in column B. Thanks

  21. #21
    Forum Contributor
    Join Date
    03-30-2020
    Location
    Wales, UK
    MS-Off Ver
    365 (Mac)
    Posts
    191

    Re: Find consecutive strings of numbers from out of order list, and calculate longest stri

    How do I mark as resolved, please?

  22. #22
    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,869

    Re: Find consecutive strings of numbers from out of order list, and calculate longest stri

    Ah! Thanks.

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

  23. #23
    Forum Contributor
    Join Date
    03-30-2020
    Location
    Wales, UK
    MS-Off Ver
    365 (Mac)
    Posts
    191

    Re: Find consecutive strings of numbers from out of order list, and calculate longest stri

    Hi. I can’t see this option on mobile version?

  24. #24
    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,869

    Re: Find consecutive strings of numbers from out of order list, and calculate longest stri

    I’ve done it for you.

+ 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. How to find duplicates of numbers in non-consecutive order?
    By shade89 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-25-2018, 08:47 PM
  2. Compare to strings for a match (string data may not be in same order)
    By Kramxel in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-09-2016, 02:47 PM
  3. [SOLVED] Longest series of consecutive 2 chars in a string
    By Eric_25 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 08-23-2014, 06:23 AM
  4. [SOLVED] My code to find longest string in column doesn't work properly! Need Help!!
    By refree in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-03-2013, 08:27 AM
  5. [SOLVED] How to find longest string in a column
    By refree in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-27-2013, 03:06 AM
  6. Need help find longest group of numbers
    By VBisgreat in forum Excel Programming / VBA / Macros
    Replies: 36
    Last Post: 03-22-2013, 03:52 PM
  7. How to find a string within another list of strings?
    By lmattenl in forum Excel General
    Replies: 7
    Last Post: 11-18-2012, 07:03 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