+ Reply to Thread
Results 1 to 13 of 13

Split contents of a cell into several cells (space as a delimiter)

  1. #1
    Registered User
    Join Date
    10-27-2010
    Location
    princeton
    MS-Off Ver
    Excel 2003
    Posts
    10

    Split contents of a cell into several cells (space as a delimiter)

    Hi,
    I have the following problem:

    In my excel sheet cell D80 contains the following values
    /bin/rm -f /home/mbprwork/start/ADP2/*_daily.adp2
    I have recorded the following macro to split the contents of this cell into adjacent cells (here i'm takling space " " as my delimiter)

    Please Login or Register  to view this content.
    The above code is splitting the values as expected ; however there is a problem with the "-f" in "/bin/rm -f /home/mbprwork/start/ADP2/*_daily.adp2"
    Once i run the code the "-f" is referenced as "#NAME?" in cell E80;
    How do i retain my original value "-f" in E80 cell.

    Any Help is greatly appreciated; thanks for your time.
    Last edited by ramky79; 11-09-2010 at 02:47 PM. Reason: solved

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,447

    Re: Split contents of a cell into several cells (space as a delimiter)

    Please Login or Register  to view this content.

    Regards
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    10-27-2010
    Location
    princeton
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Split contents of a cell into several cells (space as a delimiter)

    I have tried with this code but my minus options are still being referenced as #NAME?

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,447

    Re: Split contents of a cell into several cells (space as a delimiter)

    I recorded it as I completed the task manually. See the attached .jpg file.

    The important part is setting the second field as text.

    The raw code is:

    Please Login or Register  to view this content.


    If this doesn't work for you, you need to call in the cavalry. It worked for me in a clean, empty Excel 2003 workbook.

    I suggest that you post a sample workbook with your current code.

    Regards
    Attached Images Attached Images

  5. #5
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Split contents of a cell into several cells (space as a delimiter)

    Please Login or Register  to view this content.



  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,447

    Re: Split contents of a cell into several cells (space as a delimiter)

    The White Knight armed with some lateral thinking :-)

  7. #7
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Split contents of a cell into several cells (space as a delimiter)

    Too much honour, your honour (blushing & bowing)

  8. #8
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,447

    Re: Split contents of a cell into several cells (space as a delimiter)

    @snb: "blushing & bowing" ... that paints a picture. Just waiting for the OP to come back and say the minus sign is essential ;-)

  9. #9
    Registered User
    Join Date
    10-27-2010
    Location
    princeton
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Split contents of a cell into several cells (space as a delimiter)

    Hi TMShucks,
    your solution works for me, thank you so much.

  10. #10
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,447

    Re: Split contents of a cell into several cells (space as a delimiter)

    You're welcome. Thanks for the feedback.

  11. #11
    Registered User
    Join Date
    11-03-2011
    Location
    india
    MS-Off Ver
    Excel 2003, 2007
    Posts
    3

    Re: Split contents of a cell into several cells (space as a delimiter)


    Hi,
    Please help me out in the following...

    Selection.TextToColumns Destination:=Range("B1"), DataType:=xlDelimited, _
    TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=True, Tab:=False, _
    Semicolon:=False, Comma:=False, Space:=True, Other:=False, FieldInfo _
    :=Array(Array(1, 1), Array(2, 2), Array(3, 1)), TrailingMinusNumbers:=True

    In the above how do I replace B1 to any random cell in a worksheet? i.e. I just need the data to be split on adjacent cells of a selection no matter where I use the macro on a sheet.

    Say for example,
    In one worksheet I have the data to split at a1 and I need the split data in a1, a2, a3 etc.
    And in the next worksheet at d3 and I need the split data in d3, d4, d5, etc.

  12. #12
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,447

    Re: Split contents of a cell into several cells (space as a delimiter)

    Your post does not comply with Rule 2 of our Forum RULES. Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread.

  13. #13
    Registered User
    Join Date
    11-03-2011
    Location
    india
    MS-Off Ver
    Excel 2003, 2007
    Posts
    3

    Re: Split contents of a cell into several cells (space as a delimiter)

    sorry didn't know, will start a new thread.

+ 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