+ Reply to Thread
Results 1 to 8 of 8

“… there will be »segments«”: cutting up a sequence into smaller chunks

  1. #1
    Registered User
    Join Date
    03-15-2013
    Location
    London
    MS-Off Ver
    Excel 2016 (Mac)
    Posts
    69

    “… there will be »segments«”: cutting up a sequence into smaller chunks

    Hello everyone,

    Beginning in A1, I have a row (which I will call R1).
    This row can be of varying size (79, 25, 43, 91, etc.) but is, at the most, 100 cells long.
    The cells of R1 can contain any written element (numbers, letters, symbols, words, etc. but no formulas!).

    Now, I wish to cut up R1 into smaller segments. For this, I want to use a second row (R2).
    Beginning in A2, this row (R2) stipulates the number and size of the segments.
    These segment-numbers are never larger than 20.
    As an example, let’s say R2 is: 8, 3, 6, 6, 11, 19, etc.
    The resultant segments would then be displayed from A4 onwards.

    I would imagine it to somehow look like this:

    [A1] X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X .............. (this is R1)
    [A2] 8, 3, 6, 6, 11, 19, etc. (this R2)
    [A3]
    [A4] X, X, X, X, X, X, X, X (these are the segments)
    [A5] X, X, X
    [A6] X, X, X, X, X, X
    [A7] X, X, X, X, X, X
    [A8] X, X, X, X, X, X, X, X, X, X, X
    Etc.


    To recapitulate:
    R1 is a long row of diverse data which I have from somewhere else and which I need to cut up. Ergo, the actual content of R1 (that is, the elements in each cell as well as the actual amount of cells) will always change (but will contain a maximum of 100 cells).
    The numbers of R2 are also inputted by me and will also always change. As a rule, they are between 1 and 20; (i.e. there are no negative values in R2).

    I hope this makes sense.

    Two final points:
    1. If the numbers of R2 are not enough to partition R1, R2 will start over again (and again) until R1 is fully divided into segments.

    2. If the numbers of R2 are too many to partition R1, the function will stop automatically at the point where all elements of R1 have been divided. This would mean that R2 is not fully used.


    I have a feeling this might be difficult and better done with Macros but I don’t know enough to assess this.
    I would appreciate any pointers or advice.

    Thank you in advance.

  2. #2
    Forum Expert dredwolf's Avatar
    Join Date
    10-27-2012
    Location
    Clearwater,Canada
    MS-Off Ver
    Excel 2007
    Posts
    2,649

    Re: “… there will be »segments«”: cutting up a sequence into smaller chunks

    Try this in A4:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Drag down and across as far as needed

    see attached

    Hope this helps
    Attached Files Attached Files
    A picture may be worth a thousand words, BUT, a sample Workbook is worth a thousand screenshots!
    -Add a File - click advanced (next to quick post), scroll to manage attachments, click, select add files, click select files, select file, click upload, when file shows up at bottom left, click done (bottom right), click submit
    -To mark thread Solved- go top of thread,click Thread Tools,click Mark as Solved
    If you received helpful response, please remember to hit the * of that post

  3. #3
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: “… there will be »segments«”: cutting up a sequence into smaller chunks

    That looks good, dredwolf but I don't think it accounts for this stipulation:

    Quote Originally Posted by Schroeder70 View Post
    1. If the numbers of R2 are not enough to partition R1, R2 will start over again (and again) until R1 is fully divided into segments.
    I used this similar formula in A4 copied across to T4 and then as far down as required

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


    assumes row 3 is blank

    see attached - red "R2" values are randomly generated - press F9 to generate new numbers
    Attached Files Attached Files
    Last edited by daddylonglegs; 03-16-2013 at 06:56 PM.
    Audere est facere

  4. #4
    Forum Expert dredwolf's Avatar
    Join Date
    10-27-2012
    Location
    Clearwater,Canada
    MS-Off Ver
    Excel 2007
    Posts
    2,649

    Re: “… there will be »segments«”: cutting up a sequence into smaller chunks

    AAH...missed that daddylonglegs, nice catch

  5. #5
    Registered User
    Join Date
    03-15-2013
    Location
    London
    MS-Off Ver
    Excel 2016 (Mac)
    Posts
    69

    Re: “… there will be »segments«”: cutting up a sequence into smaller chunks

    Hello dredwolf and daddylonglegs

    The functions work very well.
    The amount of manual work you have saved me is enormous.
    Thank you both very, very much for your help.

    I have quite a few questions as I am trying to learn but I will limit myself to just one if you would:
    Can I extend the maximum number of cells for R1 to 200 or 300 (leaving everything else as it is)?
    Dredwolf's function seems to go beyond 100 cells but would not continue to partition R1 if R2 required repeating (see your posts above).
    Daddylongleg's function does indeed repeat R2 until all of R1 is divided but stops at 100 cells (as I, admittedly, asked for).
    Is it possible to combine the two?

    Thank you both again

  6. #6
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: “… there will be »segments«”: cutting up a sequence into smaller chunks

    I used the range $A$1:$CU$1 in two places - that's 100 cells - You can increase that to be as large as you want, even use $1:$1 for the whole of row 1 if you want, i.e.

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

  7. #7
    Registered User
    Join Date
    03-15-2013
    Location
    London
    MS-Off Ver
    Excel 2016 (Mac)
    Posts
    69

    Re: “… there will be »segments«”: cutting up a sequence into smaller chunks

    Thanks daddylonglegs

  8. #8
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: “… there will be »segments«”: cutting up a sequence into smaller chunks

    Actually my calculations went astray, $A$1:$CU$1 is only 99 cells .....but you get the idea

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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