+ Reply to Thread
Results 1 to 26 of 26

Extract Sequential Numbers of 5 or More Into Separate Columns

  1. #1
    Registered User
    Join Date
    01-20-2016
    Location
    Boston, MA
    MS-Off Ver
    Office 2011 Mac
    Posts
    15

    Extract Sequential Numbers of 5 or More Into Separate Columns

    Hello Everyone. I've attached a file where I place 20 #'s into columns CG-CZ, and the formula places the numbers in their corresponding column to the left. It also highlights the sequential numbers of 3 or more like in the 1st 20 examples. What I would like for it to also do is place any runs of 5 or more numbers in column DC-DV like the examples in the next 20 rows.

    I appreciate your help with this issue. Thank you.

    P.S. What are running sequential numbers considered in excel? I tried researching this on my own, but didn't know how to word it in Google.
    Attached Files Attached Files

  2. #2
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Extract Sequential Numbers of 5 or More Into Separate Columns

    etm6477 in the output example (row 24) there is an empty cell between the two "runs" of 5 numbers.

    Since there is only one occurrence of multiple runs it is difficult to tell if that is intentional.

    Is it?
    Dave

  3. #3
    Registered User
    Join Date
    01-20-2016
    Location
    Boston, MA
    MS-Off Ver
    Office 2011 Mac
    Posts
    15

    Re: Extract Sequential Numbers of 5 or More Into Separate Columns

    It was on purpose, if its easier just to just have them next to each other then thats fine because its very rare for there to be 2 or more in the same row. I just wanted 1 example because it will happen, and i didn't want it to screw up the function, or conditional formatting, if that's what you'll use.

  4. #4
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Extract Sequential Numbers of 5 or More Into Separate Columns

    OK next question.

    If we were to put space(s) between the outputs:
    In the example there is only one non-qualifying number between the runs of 5 in CG2:CZ2 and one space between the outputs in row 24.
    If there were more than one non-qualifying number between those runs how many spaces do you want in the output?

  5. #5
    Registered User
    Join Date
    01-20-2016
    Location
    Boston, MA
    MS-Off Ver
    Office 2011 Mac
    Posts
    15

    Re: Extract Sequential Numbers of 5 or More Into Separate Columns

    No need for the spaces between them then. It will be fine without them. As I said, it rarely occurs, so if they could just go next to the other run of five, or more then that's fine. Thank you.

  6. #6
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Extract Sequential Numbers of 5 or More Into Separate Columns

    This is going to take me a while.

    Using the conditional formatting formula as a guide returns the numbers. So far I have not been able to eliminate sequential runs less than 5.

  7. #7
    Registered User
    Join Date
    01-20-2016
    Location
    Boston, MA
    MS-Off Ver
    Office 2011 Mac
    Posts
    15

    Re: Extract Sequential Numbers of 5 or More Into Separate Columns

    Still looking for help on this. Just wanna move it to the top.

  8. #8
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Extract Sequential Numbers of 5 or More Into Separate Columns

    Yeah.

    Still working on it. Getting the first run of numbers is not a problem. It's where there are multiple runs that I hit snags.

  9. #9
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Extract Sequential Numbers of 5 or More Into Separate Columns

    I've exhausted all my ideas and called for community help.

  10. #10
    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,460

    Re: Extract Sequential Numbers of 5 or More Into Separate Columns

    Can you share what you did to generate the first run of numbers?
    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.

  11. #11
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Extract Sequential Numbers of 5 or More Into Separate Columns

    Sure. With two helper columns in DB:DC.

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


    Then in DD2 fill the table with this
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    In column DY are some left over formula parts I thought might take me somewhere. I left them just in case it helps someone.

  12. #12
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,152

    Re: Extract Sequential Numbers of 5 or More Into Separate Columns

    VBA offering

    Please Login or Register  to view this content.
    Attached Files Attached Files

  13. #13
    Forum Expert
    Join Date
    05-20-2015
    Location
    Chicago, Illinois
    MS-Off Ver
    2016
    Posts
    2,103

    Re: Extract Sequential Numbers of 5 or More Into Separate Columns

    EDIT: This solution misses sequences that start with numbers lower than 5. See below for a better version.


    I think I have a formula solution that works? To avoid circular references, it should start in column DE. Try the following formula in DE2, it should be array-entered (confirmed with ctrl+shift+enter instead of enter):

    =IFERROR(SMALL(IF(MATCH($CG2:$CZ2,SMALL(IFERROR((($CK2:$DD2-4)=$CG2:$CZ2)*$CG2:$CZ2,0),COLUMN($CG2:$CZ2)-COLUMN($CG2)+1),1)>IFERROR(MATCH($CG2:$CZ2-5,SMALL(IFERROR((($CK2:$DD2-4)=$CG2:$CZ2)*$CG2:$CZ2,0),COLUMN($CG2:$CZ2)-COLUMN($CG2)+1),1),COLUMN($CZ2)),$CG2:$CZ2),COLUMN(A:A)),"")

    Fill right as far as you need to and down. Take a look at the attachment to see if it's working as desired:
    Last edited by CAntosh; 04-16-2018 at 02:02 PM.
    If your problem has been solved, please use "Thread Tools" to mark the thread as "Solved".

    If you're grateful for this site's existence and would like to contribute to the community, please consider posting something hilarious in our joke thread:
    https://www.excelforum.com/the-water...ke-thread.html

  14. #14
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Extract Sequential Numbers of 5 or More Into Separate Columns

    @CAntosh,

    Bravo! Good work. I really like the approximate match approach and without helper column(s). I had about given up hope for a formula solution.

    If you are interested the nested IFERRORS can be replaced.
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Good work.

  15. #15
    Forum Expert
    Join Date
    05-20-2015
    Location
    Chicago, Illinois
    MS-Off Ver
    2016
    Posts
    2,103

    Re: Extract Sequential Numbers of 5 or More Into Separate Columns

    Thanks! Nifty trick to eliminate the IFERRORS! I noticed when checking it, though, that both solutions struggle with sequences starting below 5. Here's an ugly tweak that I think solves the problem?

    With IFERROR (array-entered):
    =IFERROR(SMALL(IF(MATCH($CG2:$CZ2,SMALL(IFERROR((($CK2:$DD2-4)=$CG2:$CZ2)*$CG2:$CZ2,0),COLUMN($CG2:$CZ2)-COLUMN($CG2)+1),1)>IFERROR(MATCH($CG2:$CZ2-5,IF(SMALL(IFERROR((($CK2:$DD2-4)=$CG2:$CZ2)*$CG2:$CZ2,0),COLUMN($CG2:$CZ2)-COLUMN($CG2)+1)=0,-5,SMALL(IFERROR((($CK2:$DD2-4)=$CG2:$CZ2)*$CG2:$CZ2,0),COLUMN($CG2:$CZ2)-COLUMN($CG2)+1)),1),COLUMN($CZ2)),$CG2:$CZ2),COLUMN(A:A)),"")

    With only the outer IFERROR (array-entered):
    =IFERROR(SMALL(IF(MATCH($CG2:$CZ2,SMALL(((N(+$CK2:$DD2)-4)=$CG2:$CZ2)*$CG2:$CZ2,COLUMN($CG2:$CZ2)-COLUMN($CG2)+1),1)>MATCH(($CG2:$CZ2-5),IF(SMALL(((N(+$CK2:$DD2)-4)=$CG2:$CZ2)*$CG2:$CZ2,COLUMN($CG2:$CZ2)-COLUMN($CG2)+1)=0,-5,SMALL(((N(+$CK2:$DD2)-4)=$CG2:$CZ2)*$CG2:$CZ2,COLUMN($CG2:$CZ2)-COLUMN($CG2)+1)),1),$CG2:$CZ2),COLUMN(A:A)),"")

  16. #16
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Extract Sequential Numbers of 5 or More Into Separate Columns

    Edit Disregard the comments about offset references. I'll blame it in my bifocals! LOL

    I noticed when checking it, though, that both solutions struggle with sequences starting below 5.
    Initially I had suspected that might be a drawback of approximated matches. I tested it on a few rows and didn't see any problems with your solution. I'll check again.

    Is there any particular row/sequence combination that you can tell me about?

    In your last attached I did notice the formula rows are offset from the source references and appear to start referencing the second row instead of the first one.

    I haven't tested it, but do you suppose that is the source of apparent error?
    Last edited by FlameRetired; 04-16-2018 at 03:16 PM.

  17. #17
    Forum Expert
    Join Date
    05-20-2015
    Location
    Chicago, Illinois
    MS-Off Ver
    2016
    Posts
    2,103

    Re: Extract Sequential Numbers of 5 or More Into Separate Columns

    Quote Originally Posted by FlameRetired View Post
    Is there any particular row/sequence combination that you can tell me about?
    On my initial effort, you can see the errors if you change any row to start with 1,2,3,4,5. The solution recognizes the streak, but only returns a 5. It happened because the "-5" in the second half of the formula creates negative numbers in the array when the values in the row are less than 5, and the ascending MATCH struggles with lookup values that are lower than anything in the MATCH array. The workaround isn't particularly elegant, but it should replace the zeroes in the lookup array with "-5"s so that the Match can operate properly.

  18. #18
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Extract Sequential Numbers of 5 or More Into Separate Columns

    Yeah. I just finished tracing all that. Excellent sleuthing.

    Thanks for answering the Cavalry call. I burned neurons on this one. Consider yourself double repped.

  19. #19
    Forum Expert
    Join Date
    05-20-2015
    Location
    Chicago, Illinois
    MS-Off Ver
    2016
    Posts
    2,103

    Re: Extract Sequential Numbers of 5 or More Into Separate Columns

    Haha, I appreciate it! This was a fun one to play with.

  20. #20
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Extract Sequential Numbers of 5 or More Into Separate Columns

    Quote Originally Posted by CAntosh View Post
    Haha, I appreciate it! This was a fun one to play with.
    I'm too exhausted to see the fun ... yet. Should have made the Cavalry call days ago. I learned some new things.

  21. #21
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Extract Sequential Numbers of 5 or More Into Separate Columns

    etm6477 we haven't heard any feedback.

    Been playing around with this. Finally came up with a formula I felt worth posting.

    Array entered in DC2 filled down and across. If you aren’t familiar with array-entered formulas array enter means the formula must be committed from edit mode by simultaneously pressing and holding down Ctrl and Shift while hitting Enter.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Last edited by FlameRetired; 05-13-2018 at 01:25 AM.

  22. #22
    Registered User
    Join Date
    01-20-2016
    Location
    Boston, MA
    MS-Off Ver
    Office 2011 Mac
    Posts
    15

    Re: Extract Sequential Numbers of 5 or More Into Separate Columns

    Hello again Everyone. I wanna first start off by thanking everyone for all their help that they've provided since I first asked this question over a year and a half ago. I appreciate it tremendously, but since then, I've had to change a couple minor things in the spreadsheet in which I continue to analyze data with.
    I've attached the same file from my initial question, but with a few changes:

    The numbers before used to go to just 80, but now the 1st 10 numbers repeat after 80 because I realized after I posted this that the numbers loop around... So the same way that 18,19,20,21,22 is a run of 5 numbers, according to the program 78,79,80,1,2 is a run of 5 numbers as well, so here lies my issues:

    I first needed to repeat the 1st 10 numbers, so with a little research I figured out the formula to get the number 1-10 to repeat

    "=IF($C52=0,"",$C52)"

    Now I'm not sure if that's the best formula to use, or I can alter the original formula of

    =IF(ISERROR(MATCH(COLUMN(A74),$CQ74:$DJ74,FALSE)),"",COLUMN(A74))

    so that it can just pull the number 1-10 from the 20 random numbers in columns CQ to DJ

    Now this is the part that goes back to my original question. I need the formula you helped me with before

    =IFERROR(SMALL(IF(MATCH($CQ74:$DJ74,SMALL(IFERROR((($CU74:$DL74-4)=$CQ74:$DJ74)*$CQ74:$DJ74,0),COLUMN($CQ74:$DJ74)-COLUMN($CQ74)+1),1)>IFERROR(MATCH($CQ74:$DJ74-5,IF(SMALL(IFERROR((($CU74:$DL74-4)=$CQ74:$DJ74)*$CQ74:$DJ74,0),COLUMN($CQ74:$DJ74)-COLUMN($CQ74)+1)=0,-5,SMALL(IFERROR((($CU74:$DL74-4)=$CQ74:$DJ74)*$CQ74:$DJ74,0),COLUMN($CQ74:$DJ74)-COLUMN($CQ74)+1)),1),COLUMN($DJ74)),$CQ74:$DJ74),COLUMN(A:A)),"")

    to also extract the runs of 78,79,80,1,2; ect.

    The example I provided will give a little more detail, but the highlighted numbers are what I need to appear in my spreadsheet, that from the original formula do not at this time.

    I appreciate ALL your help with this. It's gonna save me SO MUCH time on a daily basis, so thank you all again for whatever help you can give me with this.
    Attached Files Attached Files

  23. #23
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,535

    Re: Extract Sequential Numbers of 5 or More Into Separate Columns

    This proposal employs helper columns which may be moved and/or hidden for aesthetic purposes.
    The helper columns (EA:EF) are populated using:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Dave's array entered formula is appended so that it reads:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    (See the yellow highlighted rows)
    Let us know if you have any questions.
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

  24. #24
    Forum Expert
    Join Date
    09-30-2019
    Location
    Chiangmai, Thailand
    MS-Off Ver
    Office 2016, Excel 2019
    Posts
    1,234

    Re: Extract Sequential Numbers of 5 or More Into Separate Columns

    Please try this condition format formula at CG2

    Please Login or Register  to view this content.
    And formula for C2
    Please Login or Register  to view this content.
    Regards.
    Last edited by menem; 11-13-2019 at 04:56 AM. Reason: Add formula

  25. #25
    Registered User
    Join Date
    01-20-2016
    Location
    Boston, MA
    MS-Off Ver
    Office 2011 Mac
    Posts
    15

    Re: Extract Sequential Numbers of 5 or More Into Separate Columns

    Dave...I tried plugging 77,78,79,80,1,2,3,4 in, and it didn't work

  26. #26
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,535

    Re: Extract Sequential Numbers of 5 or More Into Separate Columns

    Not Dave, however I feel that you may be referring to post #23. I plugged in 77,78,79,80 in CW3:CZ3 then 1,2,3,4 in CG3:CJ3.
    Next I dragged the formula in EF3 over to EH3.
    Next I modified the formula in DC3 to read:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Lastly I dragged that formula over to DV3.
    Let us know if you have any questions.

+ 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 Extract Street Numbers from an Address to Separate Columns
    By SeaTiger in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-05-2017, 12:15 PM
  2. Replies: 6
    Last Post: 07-04-2016, 04:52 PM
  3. [SOLVED] Separate input numbers into separate columns.
    By Tona in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-16-2015, 04:23 AM
  4. Evaluate columns for sequential numbers and roll up
    By vlock22 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-01-2015, 01:53 PM
  5. [SOLVED] Extract and separate the letters into their own separate columns
    By siroos12 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 08-22-2013, 10:18 AM
  6. Replies: 1
    Last Post: 12-22-2011, 10:10 AM
  7. Extract Numbers From RandLotto List Into Separate Cells
    By chelseasikoebs in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-05-2009, 09:18 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