+ Reply to Thread
Results 1 to 12 of 12

Copy data from a string from one cell and paste into a different cell

  1. #1
    Forum Contributor
    Join Date
    05-13-2012
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2010
    Posts
    378

    Question Copy data from a string from one cell and paste into a different cell

    Good morning all!!!

    I have some data that I want to pull from a string within a cell and paste into a different cell using VBA. Not sure how to do this...ideas?

    Ex.

    C2 contains the following...
    NONSTOREDEVICE IM78546985

    I want to copy from the IM to the right and then paste in cell B2. Then continue this process for each row on the worksheet.

    I have used the "Right" and "Left" formulas when working with smaller sheeting. However, due to the size of this report and the fact that I am trying to speed up the time it takes me to create this report, I would like to do this using a macro.

    Ideas?????

  2. #2
    Forum Contributor
    Join Date
    10-08-2010
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    386

    Re: Copy data from a string from one cell and paste into a different cell

    There is a left right function in VBA, used in exactly the same way.

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    05-13-2012
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2010
    Posts
    378

    Re: Copy data from a string from one cell and paste into a different cell

    Thanks!

    What is the best way to make this formula loop through each row to until that last populated row?

  4. #4
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Copy data from a string from one cell and paste into a different cell

    Try this
    Please Login or Register  to view this content.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  5. #5
    Forum Contributor
    Join Date
    05-13-2012
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2010
    Posts
    378

    Re: Copy data from a string from one cell and paste into a different cell

    Thanks!

    That code worked perfectly!

    Is there a way that I can only have this formula work if it contains "IM"?

  6. #6
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Copy data from a string from one cell and paste into a different cell

    Updated code
    Please Login or Register  to view this content.
    Last edited by arlu1201; 07-05-2012 at 10:11 AM.

  7. #7
    Forum Contributor
    Join Date
    05-13-2012
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2010
    Posts
    378

    Re: Copy data from a string from one cell and paste into a different cell

    That is BEAUTIFUL!!! Works perfectly!!!

    I have noticed that apparently I have some carriage returns within the cells. How can I trim/remove those within this code?

  8. #8
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Copy data from a string from one cell and paste into a different cell

    I have edited the code in post 6. Let me know if it works.

  9. #9
    Forum Contributor
    Join Date
    05-13-2012
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2010
    Posts
    378

    Re: Copy data from a string from one cell and paste into a different cell

    Didn't work.

  10. #10
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Copy data from a string from one cell and paste into a different cell

    Do you have a sample of the data?

  11. #11
    Forum Contributor
    Join Date
    05-13-2012
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2010
    Posts
    378

    Re: Copy data from a string from one cell and paste into a different cell

    I have uploaded a sample of what I am trying to work with. The cells highlighted in yellow are the cells with the carriage return.
    Attached Files Attached Files

  12. #12
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Copy data from a string from one cell and paste into a different cell

    Since you are already working out the carriage return issue in this thread - http://www.excelforum.com/excel-prog...with-text.html and its an additional part of this thread, i would suggest you mark this solved and attach your file in the other thread.

    This will save you from the threads being flagged as duplicates.

+ 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