+ Reply to Thread
Results 1 to 4 of 4

Split string and copy

  1. #1
    Forum Contributor
    Join Date
    11-18-2007
    Posts
    111

    Split string and copy

    Hi,
    Here is what I am trying to do: I am trying to copy a part of a string and copy it into another columns (Package Size and Package Quantity) but there are 3 scenarios in this problem:
    1) NEUPOGEN 480M CG/1.6 VL 10X1.6 ML
    2) LOVENOX 40 MG PFS 10
    3) COMBIVENT 200 ACT INH 14.7 GM
    So let me explain here what I want to do here:
    Scenario 1) whenever we have ‘X’, everything to the right of ‘X’ is Package Size and everything to the left of ‘X’ is Quantity
    Scenario 2) Whenever the last words in a string are just ‘Numbers’ then that number should be the ‘Package Quantity’ and the ‘Package Size’ is ALWAYS ‘1’
    Scenario 3) Whenever we have numbers at the end followed by letters like GM or ML at last, then this number should be Package Size and the Package Quantity is ALWAYS 1.

    So this is what the example above should look like:
    Package Size Package Quantity
    Scenario 1) 1.6 10
    Scenario 2) 1 10
    Scenario 3) 14.7 1

    The code below works but would like to make some changes to reflect the example above and the solution could be in any format as long as it works I am fine with it. Pls. see attached sample file. Thanks for your help.

    HTML Code: 
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: How to split string and copy

    Cross-posted here

    http://www.experts-exchange.com/Prog..._26110356.html

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

    Re: How to split string and copy

    Hello karinos57,

    This macro will parse the data and places the results in columns "I" and "J". The offsets are measured from column "B". You can change these to copy the data into the columns you choose. I added a button to run the macro. There are 3 lines highlighted in yellow where the your entries and the parsed data differ.
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

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

    Re: Split string and copy

    As outlined this was x-posted but also duped on this forum:

    http://www.excelforum.com/excel-work...-and-copy.html

    karinos57, if you wish to continue posting on this forum please find the time to read and subsequently adhere to forum rules.

    If you continue to run the risk of wasting people's (free) time you will find your posts are soon ignored altogether.

+ 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