+ Reply to Thread
Results 1 to 7 of 7

Distribute contents of a cell into other cells according to number of characters

Hybrid View

  1. #1
    Registered User
    Join Date
    11-22-2012
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    26

    Distribute contents of a cell into other cells according to number of characters

    Hi, I wonder if any one can figure out a formula to to the following:

    The users enter terms separated by spaces into a single cell. Then I have to later make sure that when those terms go over 50 characters, that I distribute them into as many as a total of three cells, with a maximum of 50 characters each.

    So I wanted to build a formula that would automate my task, or at least help a little bit. The perfect formula would do this:

    Say the text is on A1: cold jacket plaid pockets zipper hood cotton leather outwear fashion woolly silky designer comfy trendy casual smart (a total of 116 characters)


    I have to spread this into B1, C1 and D1 and not go over 50 characters in each of them. So my formula would go like

    On B1 = A1 up to the last space before reaching character #50 (cold jacket plaid pockets zipper hood cotton )
    On C1 = A1 starting to count on first word after last on B1 up to the last space before reaching character count 50 (leather outwear fashion woolly silky designer )
    On D1 = The remaining words: comfy trendy casual smart

    The users have a limit of 150 with data validation (giving them the three columns is not an option though)

    What I do now is really pitiless: I put a LEN formula on B1 to get an idea of how many cells I need, then just manually cut and paste the text many, many, many times a day

    Thank you for any ideas!

    Marcia

  2. #2
    Valued Forum Contributor fredlo2010's Avatar
    Join Date
    07-04-2012
    Location
    Miami, United States
    MS-Off Ver
    Excel 365
    Posts
    762

    Re: Distribute contents of a cell into other cells according to number of characters

    Hello,

    what you need a the MID function:

    In cell B1:
    Formula: copy to clipboard
    =MID($A1,(COLUMN(A1)*50+1)-50,50)


    Once you input the first formula you just grab the handles and drag as many cells to the right as you want. In this case up to D1

    Thanks

  3. #3
    Valued Forum Contributor
    Join Date
    10-29-2012
    Location
    Mojokerto,Indonesia
    MS-Off Ver
    Excel 2007
    Posts
    554

    Re: Distribute contents of a cell into other cells according to number of characters

    at B1
    =MID($A1,COLUMNS($A:A)*50-49,50)
    copy to right

  4. #4
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,655

    Re: Distribute contents of a cell into other cells according to number of characters

    You will get some errors like B2 or C2 may contains partial words based on length count done with the formula. VBA may provide a better solution to it so that you get sentences with complete words in cells. Like as per your example you will get the text in Cells B2, C2 and D2 as below......

    B2 = cold jacket plaid pockets zipper hood cotton
    C2 = leather outwear fashion woolly silky designer
    D2 = comfy trendy casual smart

    Please find an attached workbook and put text in rows in column A for as many rows as per your requirement and then run the macro "DistributeContent" to get the desired result for all the rows in column A.

    Hope it helps you.
    Attached Files Attached Files
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

  5. #5
    Registered User
    Join Date
    11-22-2012
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    26

    Re: Distribute contents of a cell into other cells according to number of characters

    Thank you all! I was not familiar with the MID function and am really glad I learned it now.

    And the macro is perfect!

    Very helpful, thank you again.

  6. #6
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Distribute contents of a cell into other cells according to number of characters

    I'm not a programmer but it seems that this would be best handled using a UDF.

    Would it be possible to write this as a UDF taking these arguments:

    =ParseString(cell_ref,num_of_characters)

    To be used as:

    =ParseString($A2,50)

    Or:

    =ParseString(A$2,50)

    Which could be drag copied across the row or down a column.

    Once all the segments have been extracted then the function would start returning blanks.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  7. #7
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,655

    Re: Distribute contents of a cell into other cells according to number of characters

    Glad that it helped you. Thanks for the feedback and Adding Reputation.

+ 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. Take a number and distribute that same number over a number of cells.
    By jorarden in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-25-2013, 01:47 PM
  2. Macro to Divide a Data in Cells and Distribute to X number of Columns
    By paul.serrato in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-12-2013, 12:01 AM
  3. Copy contents of one cells and distribute between a maximum of 6 different cells
    By wadapav in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-25-2013, 12:23 PM
  4. Replies: 0
    Last Post: 07-20-2012, 08:32 PM
  5. Split merged cells and distribute contents
    By eugene w in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-03-2009, 08:09 PM

Tags for this Thread

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