+ Reply to Thread
Results 1 to 5 of 5

Copy data from one workbook in a range to another workbook

  1. #1
    Registered User
    Join Date
    01-07-2013
    Location
    Canada
    MS-Off Ver
    Excel 2003
    Posts
    3

    Copy data from one workbook in a range to another workbook

    Hi everyone,

    I am trying to write a VB code that allows me to paste data from a selected range on a sheet to another sheet in a seperate workbook by clicking a button.
    I was able to write the following with success from one sheet (Broker 1) to the next (master) within the same workbook. Is there a way for me to modify the existing working form to paste the data into an external workbook e.g: C:/folder name/master.xls, sheet named "master" saved in the same folder?

    Sub Button208_Click()
    Dim NR As Long
    Dim wsCF As Worksheet
    Dim wsMA As Worksheet

    Set wsCF = Sheets("Broker 1")
    Set wsMA = Sheets("Master")
    NR = wsMA.Range("A" & Rows.Count).End(xlUp).Row + 1

    wsCF.Range("T5:AE5").Copy
    wsMA.Range("A" & NR).PasteSpecial xlPasteValues

    End Sub

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Copy data from one workbook in a range to another workbook

    You would need to open the closed workbook to paste data into it.
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    01-07-2013
    Location
    Canada
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Copy data from one workbook in a range to another workbook

    But is there a way to open the workbook and paste the data?
    E.g:

    Sheets("Broker 1").Range("T5:AE5").Copy
    Workbooks.Open ("C:/folder name/master.xls")
    Sheets("Master").Activate

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Copy data from one workbook in a range to another workbook

    Not sure what you mean.

    You can open the workbook and paste to it but not in one go.
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    01-07-2013
    Location
    Canada
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Copy data from one workbook in a range to another workbook

    Thanks I will try that.. I also encountered another problem.. I have 156 sheets each with an object button on it which allows the user to transfer data to the 'master' each sheet has a different name. Is there is a way for me to reference all the sheets instead of creating a macro for each button on every sheet?

+ 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