+ Reply to Thread
Results 1 to 6 of 6

Paste data from one worksheet to another workbook using command button

Hybrid View

  1. #1
    Registered User
    Join Date
    04-12-2014
    Location
    USA
    MS-Off Ver
    Office 365
    Posts
    8

    Paste data from one worksheet to another workbook using command button

    Hi Experts. I am hoping you can help me. I have created a log in excel which contains two text boxes and two combo boxes (activeX controls). When the command button is clicked, I would like the data in the text boxes to be transferred to the tab that has the same name as the selection in combobox1 and the column on that tab that has the same name as the data in combobox 2. The location of these tabs and columns is in another workbook.

    So, data is entered in workbook1 (Errors). When I click command button, the date (textbox1) and value (textbox2) should be transferred to workbook2 (Tracker) and placed on the next available row on the tab that has the same name as what is in combobox 1 (Type). The date should always be in column A, and the value in textbox2 should appear in the same row as the date, but in the column that has the same name as what was in combobox2. Data from all boxes should clear after clicking command button. If anyone can help me, I would appreciate it. Thanks.
    Attached Files Attached Files

  2. #2
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,138

    Re: Paste data from one worksheet to another workbook using command button

    I noticed you have a Summary page in the Errors workbook.

    Have you thought about adding all the errors to that sheet, then push all the data out after keying in all the data?

    I do this similar job and I like being able to look over the data BEFORE I push it all out for archive.
    David
    (*) Reputation points appreciated.

  3. #3
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,138

    Re: Paste data from one worksheet to another workbook using command button

    Here is WB with current request. This tests whether the WB is open or not and Opens/Closes WB as required.

    I edited a few other places as well. You don't want to clear Combobox1 after the workbook opens. Just combobx2 after you post the record.

    HTH
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    04-12-2014
    Location
    USA
    MS-Off Ver
    Office 365
    Posts
    8

    Re: Paste data from one worksheet to another workbook using command button

    Hi Tinbendr. Thanks so much for your help. See you noticed the summary tab. My original thought was to have all of the data go to the summary tab so that I can review/edit if necessary before moving to the next workbook. But, that wasn't working for me either, so I just went the direct route. Would I need another macro to do that?

    I tried the code you provided and it works perfectly when the second workbook (Tracker) is open, but not when it is closed. I get Run-time error '1004' tracker.xlsx could not be found. Debugger points to 'Set WB2 = Workbooks.Open(WBDestName, False, False). Do I need to add the path for the tracker.xlsx workbook to the code? Thanks again.

  5. #5
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,138

    Re: Paste data from one worksheet to another workbook using command button

    Yes, you'll need a path if the workbook is not in the same directory as the Error file.

    Add the following

    Dim MyPath As String
    MyPath = "C;\My Documents\"
    'then change
    Set WB2 = Workbooks.Open(MyPath & WBDestName, False, False)
    See you noticed the summary tab. ... Would I need another macro to do that?
    Yes.

    Try this one out and see how it goes. If you want to use the summary page idea, then start a new thread and link to this one.

  6. #6
    Registered User
    Join Date
    04-12-2014
    Location
    USA
    MS-Off Ver
    Office 365
    Posts
    8

    Re: Paste data from one worksheet to another workbook using command button

    That did it !! Thanks so much for taking the time to help me. I will start a new thread for the summary!!

+ 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. Active x controls command button opening worksheet in the same workbook
    By lechev65 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-06-2014, 07:27 AM
  2. Replies: 0
    Last Post: 07-24-2013, 01:09 PM
  3. command button VBA to send automated email not workbook or worksheet
    By lpratt in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-08-2012, 11:13 PM
  4. copy and paste data from one worksheet cell to another using command button
    By jasonruiz in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-13-2011, 04:34 AM
  5. [SOLVED] command button move worksheet from one workbook to another
    By Qaspec in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-02-2005, 09:06 AM

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