+ Reply to Thread
Results 1 to 8 of 8

cut a portion of a cell's contents and paste the cut portion into the net column

  1. #1
    Registered User
    Join Date
    10-11-2010
    Location
    New Jersey
    MS-Off Ver
    Excel 2003
    Posts
    1

    cut a portion of a cell's contents and paste the cut portion into the net column

    I am looking for a script to cut a portion of a cell's contents and then paste that cut portion into the cell in the next column.

    Sample data:

    Column A
    30 tablets
    100 soft gels
    50 capsules
    1 unit
    3 bottles
    4 ounces

    Desired output:

    Column A
    30
    100
    50
    1
    3
    4

    Column B
    tablets
    soft gels
    capsules
    unit
    bottles
    ounces

    The first characters will always be numbers, then a space followed by text. There will always be a space between the number and the text. Any help is greatly appreciated!

    Evan

  2. #2
    Forum Contributor pr4t3ek's Avatar
    Join Date
    10-13-2008
    Location
    Melbourne, Australia
    MS-Off Ver
    2003 & 2007, 2010
    Posts
    483

    Re: cut a portion of a cell's contents and paste the cut portion into the net column

    put this in cell b1
    Please Login or Register  to view this content.
    and this in cell C1

    Please Login or Register  to view this content.
    it will do the same
    --
    Regards
    PD

    ----- Don't Forget -----

    1. Use code tags. Place "[code]" before the first line of code and "[/code"]" after the last line of code. Exclude quotation marks

    2. Thank those who have helped you by Clicking the scales above each post.

    3. Please mark your post [SOLVED] if it has been answered satisfactorily.

  3. #3
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: cut a portion of a cell's contents and paste the cut portion into the net column

    Code wise - one possible approach:

    Please Login or Register  to view this content.
    assumes strings are in A [and of reasonable length] - adjust as nec.

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

    Re: cut a portion of a cell's contents and paste the cut portion into the net column

    or
    Please Login or Register  to view this content.



  5. #5
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: cut a portion of a cell's contents and paste the cut portion into the net column

    @snb, IMO use of TtC is risky given we don't know:

    a) number of spaces that may occur in any given string

    b) whether or not we can override C etc...
    If we assume that TtC is viable then IMO it would still be a good idea to add code to subsequently "reset" TtC from Space delimiter - so as to prevent unexpected separation going forward.

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

    Re: cut a portion of a cell's contents and paste the cut portion into the net column

    @DonkeyOte

    My suggestion is based on the information the OP provided.
    Since no example workbook is posted I do not 'create' more constraints than presented by the OP.
    If TexttoColumns is always specified for all kinds of delimiters 'resetting' shouldn't be necessary.

  7. #7
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: cut a portion of a cell's contents and paste the cut portion into the net column

    Quote Originally Posted by snb
    If TexttoColumns is always specified for all kinds of delimiters 'resetting' shouldn't be necessary.
    If you copy & paste text from an external app. into Excel then you are open to the last TtC delimiter being applied to the copied value(s).

    IMO it is a good idea to reset TtC delimiters though as mentioned that is my subjective opinion and I do not expect you to agree...

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

    Re: cut a portion of a cell's contents and paste the cut portion into the net column

    Nevertheless I like your pleonasms ....

+ 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