+ Reply to Thread
Results 1 to 18 of 18

text to rows ?

  1. #1
    Registered User
    Join Date
    08-15-2010
    Location
    melbourne, australia
    MS-Off Ver
    Excel 2007
    Posts
    39

    text to rows ?

    Hi all,
    I need help: i have data that contains many variabels in one cell, for example
    company A 10-02-2010 5000
    23-05-2009 3000
    04-04-2009 2000

    all variables in each column is in one cell, so there are 3 cells in total in above case for example.
    I need this to be changed to this:
    company A 10-02-2010 5000
    company A 23-05-2009 3000
    company A 04-04-2009 2000

    with each variables in its own cell so there are 9 cells in total

    of course I have data for more than one company

    suggestions ?

    sample included

    thank you !!
    Attached Files Attached Files

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: text to rows ?

    Try this macro.

    Please Login or Register  to view this content.
    Open up the VBA editor by hitting ALT F11

    Insert a new module by hitting Insert - Module

    Paste the macro into the empty sheet

    Hit ALT F11 to get back to the worksheet.

    Run the macro by going to tools-macro in Excel 2003 or the view ribbon in Excel 2007.
    Martin

  3. #3
    Registered User
    Join Date
    08-15-2010
    Location
    melbourne, australia
    MS-Off Ver
    Excel 2007
    Posts
    39

    Re: text to rows ?

    is this applicable to larger set of data ?
    I actually have much more rows and also more columns then the one in my sample

    thank you !!

  4. #4
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: text to rows ?

    The code will automatically adjust to the number of rows but currently puts the new data in columns 5 -7 which were blank in your example. If you have more columns in your set, then you will need to adjust the number 5 in the inner loop and add further lines to this sections of the code to cope with the extra columns.

    It's always best to describe the problem fully as we can only answer the question that is asked.

  5. #5
    Registered User
    Join Date
    08-15-2010
    Location
    melbourne, australia
    MS-Off Ver
    Excel 2007
    Posts
    39

    Re: text to rows ?

    mmmm, the problem is that I need to do this for many data sets and the number of columns vary. That's why I just post the simplest case
    is there easier way to do this beside macro ?

    thank you !!

  6. #6
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: text to rows ?

    A macro is still the best way.

    If the code was modified to detect the number of columns and dump the output on a new (and therefore blank sheet), would this help?

    Could you post a 'worst case' for test purposes?

  7. #7
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: text to rows ?

    Try thi mod of mrices' code

    Hold that result, my apologies!
    Last edited by Marcol; 09-11-2010 at 01:43 PM. Reason: Error in code

  8. #8
    Registered User
    Join Date
    08-15-2010
    Location
    melbourne, australia
    MS-Off Ver
    Excel 2007
    Posts
    39

    Re: text to rows ?

    oh yes of course, with such code I could use it with any data set with different number of columns


    this is one of the worst case with 14 columns
    i still only post 3 rows however, because you said rows dont matter, although in reality i have about 500

    also i dont know if this will make it more difficult but sometimes there will be missing data (see the last column), in which case I still need it to be transferred to the new cell but left blank (not deleted or anything. hope this makes sense.

    thank you !!
    Attached Files Attached Files

  9. #9
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: text to rows ?

    OK, try this.

    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    08-15-2010
    Location
    melbourne, australia
    MS-Off Ver
    Excel 2007
    Posts
    39

    Re: text to rows ?

    it works perfectly
    thank you !!

  11. #11
    Registered User
    Join Date
    08-15-2010
    Location
    melbourne, australia
    MS-Off Ver
    Excel 2007
    Posts
    39

    Re: text to rows ?

    Hi I actually notice a problem with the code, some of my observations that does not have value are deleted, but I need it to be there with blank cells

    sample included, result of applying the code is in sheet 4, deltathree is deleted here, is it possible to modify the code to have it not deleted, but just being there with blanks ??
    thank you !!
    Attached Files Attached Files

  12. #12
    Registered User
    Join Date
    08-15-2010
    Location
    melbourne, australia
    MS-Off Ver
    Excel 2007
    Posts
    39

    Re: text to rows ?

    anyone could help ?
    thank you !

  13. #13
    Registered User
    Join Date
    08-15-2010
    Location
    melbourne, australia
    MS-Off Ver
    Excel 2007
    Posts
    39

    Re: text to rows ?

    another thing I notice is that if the cells contains a number of dates the month and date will be exchanged ? i.e 01/05/1982 will become 05/10/1982 for example
    but if the days is larger than 12 since excel will store it as text ? i.e 15/05/1982 will still become 15/05/1982 after I apply the macro but will be stored as text

    thank you !!

  14. #14
    Registered User
    Join Date
    09-13-2010
    Location
    jkt, indonesia
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: text to rows ?

    im having the same problem
    anyone can give solution ?

  15. #15
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: text to rows ?

    Try this variation.

    Please Login or Register  to view this content.

  16. #16
    Registered User
    Join Date
    08-15-2010
    Location
    melbourne, australia
    MS-Off Ver
    Excel 2007
    Posts
    39

    Re: text to rows ?

    thank you !!!

  17. #17
    Registered User
    Join Date
    08-15-2010
    Location
    melbourne, australia
    MS-Off Ver
    Excel 2007
    Posts
    39

    Re: text to rows ?

    Interestingly, I used the code today in another computer and it still gives inconsistent month and date for each date that have value above 12
    I was pretty sure that I get the correct result when I was working from home yesterday

    is this a bug in excel or something ?

  18. #18
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: text to rows ?

    Might be something to do with regional settings which specify date formats.

+ 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