+ Reply to Thread
Results 1 to 3 of 3

Copy data from row and paste into user form

  1. #1
    Registered User
    Join Date
    09-13-2012
    Location
    Atlanta, Georgia
    MS-Off Ver
    Excel 2010
    Posts
    32

    Copy data from row and paste into user form

    Right now I have four text boxes in a userform and I manually copy text from 4 cells into each text box. It would be nice if I could copy cells A1:D1 and "paste" the results into the text boxes all at once. It's ok if I have to use a "paste" button instead of the traditional ctrl+v.

    I guess the real problem is after I copy cells in excel I don't know how to manipulate or use it in a useful way in vba. Is it stored as an array?
    Last edited by lwflip; 08-18-2017 at 10:52 AM. Reason: solved

  2. #2
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Copy data from row and paste into user form

    Hello
    You can add a command button to your userform and add this code
    Please Login or Register  to view this content.
    < ----- Please click the little star * next to add reputation if my post helps you
    Visit Forum : From Here

  3. #3
    Registered User
    Join Date
    09-13-2012
    Location
    Atlanta, Georgia
    MS-Off Ver
    Excel 2010
    Posts
    32

    Re: Copy data from row and paste into user form

    Hello. Sorry this won't work in my case. The cells that I actually copy aren't in a static location. Sometimes it's a different worksheet or workbook. I was hoping to keep it flexible so I can find the data I need, highlight it, hit ctrl+c, then paste into the form.

    Edit - I was able to find a solution but I need some help tweaking it/error handling.

    The first issue is the last textbox always seems to carry some extra characters. For instance, if I copy 4 cells the last text box has a paragraph symbol. If I copy 4+ cells the last textbox is a combination of the 4th cell and the 1st cell of the 2nd row, with the addition of a paragraph symbol separating them. Is there a way to fix this so the last textbox only shows the valve of the 4th copied cell?

    The second issue is the code breaks if I don't have at least 4 columns copied. I'm still not sure how I should be parsing the clipboard string. I would like to exit the sub if the array doesn't have at least 4 items.

    Please Login or Register  to view this content.
    Edit 2 - Okay I figured it out but it is a very crude method and there is definitely a better way.

    Please Login or Register  to view this content.
    Last edited by lwflip; 08-18-2017 at 10:51 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Paste the Data in different row or column through User Form
    By Nisha Dhawan in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-27-2015, 02:29 AM
  2. [SOLVED] text box data in a user form copy to a range in sheet 3
    By 9599lorenzo in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-17-2015, 09:22 AM
  3. VBA code to copy data from Excel data table to user form
    By Srikanth H N in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-03-2014, 11:53 AM
  4. Copy data from cell to user form
    By msaric in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-18-2013, 07:25 PM
  5. Populate from user form then copy & paste to another worksheet
    By zimbo109 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 04-24-2010, 12:41 PM
  6. Copy and paste from one user form to another
    By ducecoop in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 11-18-2008, 10:04 PM
  7. Need to Paste data into User Form fields or convert
    By iturnrocks in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-02-2008, 04:12 PM

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