+ Reply to Thread
Results 1 to 20 of 20

Split Cell by Delimiter, Move to New Row...

  1. #1
    Registered User
    Join Date
    09-03-2008
    Location
    Royal Oak, MI
    Posts
    18

    Split Cell by Delimiter, Move to New Row...

    Help would be greatly appreciated. I'm really struggling with this. I'm prepping this file to be pushed through mail merge. The sheet has 25,213 rows.

    Column I contains a long string of character (for the purposes of my project the field is called Subjects) and $ used as delimiters (approx 70 or as few as 1). This column needs to be split apart by $ and the separate Subjects that result from splitting apart by $ needs to be placed on a separate line. Once each Subject is on a separate line, all of the Subjects need to be lined up in Column I, one under another (the obvious result at this point is GREATLY increasing the number of rows in the sheet). Next, all of the data that is contained in each Subject's originating row will be copied to each of newly created rows (without copying over the Subject contained in column I).

    After writing this all out, I realize (once again), how hopeless I am without outside help. THANK YOU!!!! in advance.

    Pete

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello jpfulton,

    Welcome the Forum!

    I have a couple of questions about the data. You say the data in column "I" is delimited by "$" characters. If the entry is a single value will it always be terminated with a "$" also? Will there be any blanks in this column? Which version of Excel are you using?

    Examples
    1) "Data$
    2) "Data"

    Sincerely,
    Leith Ross

  3. #3
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    Perhaps something like
    Please Login or Register  to view this content.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  4. #4
    Registered User
    Join Date
    09-03-2008
    Location
    Royal Oak, MI
    Posts
    18
    Quote Originally Posted by Leith Ross View Post
    Hello jpfulton,

    Welcome the Forum!

    I have a couple of questions about the data. You say the data in column "I" is delimited by "$" characters. If the entry is a single value will it always be terminated with a "$" also? Will there be any blanks in this column? Which version of Excel are you using?

    Examples
    1) "Data$
    2) "Data"

    Sincerely,
    Leith Ross
    Thanks for responding.

    Single values will not be terminated with a $.
    The column will contain some blanks.
    The version of excel is 2003.

  5. #5
    Registered User
    Join Date
    09-03-2008
    Location
    Royal Oak, MI
    Posts
    18
    mikerickson,

    tried your code (this is probably a simple fix), and it doesn't work on my workbook. chokes with error "Run-time error '9'": Subscript out of range then it shows me that line 5 "Set DestinationSheet" is the problem. Strange to me b/c I'm running it on a workbook with a sheet called "Sheet2" ???

    Any idears?

  6. #6
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    Is there a Sheet1? Sometimes the line after the problem is highlighted.
    Also, my code looks to Column A. It needs to be modified to Col I (.Cells(1,9))

  7. #7
    Registered User
    Join Date
    09-03-2008
    Location
    Royal Oak, MI
    Posts
    18
    Yep... there's a Sheet1 as well.

    I'll be sure to adjust the code to point to column I instead of A, but I imagine that this error shouldn't appear as a result of that???

    I'll check it again tomorrow when I have the file in front of me...

    thanks!

  8. #8
    Registered User
    Join Date
    09-03-2008
    Location
    Royal Oak, MI
    Posts
    18
    I've adjusted the part of the code that references Column A to refer to Column I... still no fix... I'm still getting the same error as shown above...

    Any other ideas??

    thx

  9. #9
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    The spelling of the sheet name should be checked, perhaps there is an unwanted space.
    Also this code refers to the name that is on the sheet tab, not to the code name.

  10. #10
    Registered User
    Join Date
    09-03-2008
    Location
    Royal Oak, MI
    Posts
    18
    Quote Originally Posted by mikerickson View Post
    The spelling of the sheet name should be checked, perhaps there is an unwanted space.
    Also this code refers to the name that is on the sheet tab, not to the code name.
    I retyped that entire line in the code you supplied and then deleted and created a new tab called Sheet2... case sensitive and all... grrr...

    I'm going to try a new sheet name (guess I should've tried that before)...

    This also errors out on a blank workbook

  11. #11
    Registered User
    Join Date
    09-03-2008
    Location
    Royal Oak, MI
    Posts
    18
    okay... i'm trying to debug by simplifying

    I've taken little steps toward complete simplification (still getting errors along the way).

    I'm at the point now that I am working with a new workbook, 1 blank worksheet, 4 lines of code, and still getting the error...

    Will somebody else try this code please and tell me if they get the error?

    Please Login or Register  to view this content.
    Same error, whether I have two worksheets, regardless of what I call them, etc.... I have tried everything I can think of.

  12. #12
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    Try
    Please Login or Register  to view this content.
    If that doesn't work, manualy selecing Sheet2 and running this might be enlightening.
    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    09-03-2008
    Location
    Royal Oak, MI
    Posts
    18
    i feel like i'm getting post-happy... so forgive me...

    but a few minutes ago, I discovered that the problem appears to be switching worksheets... I changed the destinationsheet and the sourcesheet both to Sheet1... no errors

    I changed:

    Set SourceSheet = ThisWorkbook.Sheets("Sheet1")
    Set DestinationSheet = ThisWorkbook.Sheets("Sheet2")
    To:
    Set SourceSheet = ActiveWorkbook.Sheets("Sheet1")
    Set DestinationSheet = ActiveWorkbook.Sheets("Sheet2")
    And that runs without errors... not sure if it works right (seems that it might now)... but maybe cause I haven't readjusted for Column I


    *******EDIT*************

    It worked... now i've closed the workbook and re-opened... i can't get it to work again

    I feel like i'm losing my mind.
    Last edited by jpfulton; 09-04-2008 at 10:39 AM. Reason: i'm dumb

  14. #14
    Valued Forum Contributor rwgrietveld's Avatar
    Join Date
    09-02-2008
    Location
    Netherlands
    MS-Off Ver
    XL 2007 / XL 2010
    Posts
    1,671
    Why not add the excel file?

    Try this:

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

  15. #15
    Registered User
    Join Date
    09-03-2008
    Location
    Royal Oak, MI
    Posts
    18
    okey dokey... ha... I had to delete the last 19,000 rows... but this will probably give you enough of an idea... good ol' card catalog
    Attached Files Attached Files

  16. #16
    Registered User
    Join Date
    09-03-2008
    Location
    Royal Oak, MI
    Posts
    18
    Okay, I've attached a before and after of part of the file that I have manually converted (and color-coded). Note... Column I has been moved to Column K. Column K has been split, then if there is data in any of the columns to the right of Column K as a result of the split, the data is moved down to the next available row. Once all of the moving of the split column is complete, the rest of the ORIGINAL ROW's data is copied down until a row that is pre-existing is found.

    I'm thinking the files will explain this better than my words possibly can.

    thx again.
    Attached Files Attached Files

  17. #17
    Registered User
    Join Date
    09-03-2008
    Location
    Royal Oak, MI
    Posts
    18
    Does anybody know where I can cross-post this? I'm really desperate for help... I figured with my latest attachments somebody would be able to help.

  18. #18
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    I haven't read the whole thread, but perhaps this:
    Please Login or Register  to view this content.
    Last edited by shg; 09-05-2008 at 12:39 PM. Reason: Minor clean-up -- eliminate a loop

  19. #19
    Registered User
    Join Date
    09-03-2008
    Location
    Royal Oak, MI
    Posts
    18
    THANK YOU so much! It appears to work perfectly. I might need a couple variations. I might be able to figure out how to tweak it if someone can take that code and adjust it for the following... I will attach LCtest1.xls which will be the before and LCtest3.xls which will be the after (you will notice the slight difference between the LCtest2.xls that was attached before and LCtest3.xls that I'm attaching now).

    Note on LCtest3.xls: In the title column the new rows are to be filled in with "See also [reference to originating subject field] then part of the pub info field [date published]"

    I understand that pulling out a portion of a field in completely inconsistent data, is a tall chore... If code can be written to ROUGHLY accomplish this, I can do some creative find and replace+manual work to get it done.

    again... thank you!
    Attached Files Attached Files
    Last edited by jpfulton; 09-05-2008 at 02:10 PM.

  20. #20
    Registered User
    Join Date
    09-03-2008
    Location
    Royal Oak, MI
    Posts
    18
    I know this must be possible, shg basically wrote the code. Please see my last post. Thank 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. [SOLVED] Move sheet and save as cell value
    By Safecracker in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 04-11-2013, 07:05 AM
  2. Arrow Keys Move Window Not Cell
    By TOADSTOOL in forum Excel General
    Replies: 5
    Last Post: 01-25-2012, 02:19 PM
  3. move active cell
    By jcavigli in forum Excel General
    Replies: 2
    Last Post: 09-04-2008, 10:37 AM
  4. Replies: 7
    Last Post: 06-28-2008, 10:40 AM
  5. split cell
    By Chandrashekhar in forum Excel General
    Replies: 1
    Last Post: 03-23-2007, 05:13 AM

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