+ Reply to Thread
Results 1 to 4 of 4

Copy data from one workbook to another

  1. #1
    Registered User
    Join Date
    11-17-2005
    Posts
    3

    Copy data from one workbook to another

    Hi everyone,

    I would like to copy data from a sheet in one workbook to another sheet in a differrent workbook. Is there a way to do this automatically?

    Thank you very much for your help.

    With your help with this, i will finish up my report automation and it will save me at least 4hrs a week.

    Thanks!

  2. #2
    Jim Thomlinson
    Guest

    RE: Copy data from one workbook to another

    Here is some code that copies form one book to another...

    Sub Test()
    Dim wbkSource As Workbook
    Dim wbkDestination As Workbook
    Dim wksSource As Worksheet
    Dim wksDestination As Worksheet
    Dim rngSource As Range
    Dim rngDestination As Range

    'Set your source
    Set wbkSource = ThisWorkbook
    Set wksSource = wbkSource.Sheets("Sheet1")
    Set rngSource = wksSource.Cells

    'Set your destination
    On Error GoTo OpenBook
    Set wbkDestination = Workbooks("ThatBook.xls")
    On Error GoTo 0
    Set wksDestination = wbkDestination.Sheets("Sheet1")
    Set rngDestination = wksDestination.Range("A1")

    'You now have all of your souce and destination objects

    wksSource.Copy wksDestination
    rngSource.Copy rngDestination

    Exit Sub

    OpenBook:
    Set wbkDestination = Workbooks.Open("C:\Thatbook.xls")
    Resume Next
    Exit Sub

    End Sub
    --
    HTH...

    Jim Thomlinson


    "Excel_Newbie" wrote:

    >
    > Hi everyone,
    >
    > I would like to copy data from a sheet in one workbook to another sheet
    > in a differrent workbook. Is there a way to do this automatically?
    >
    > Thank you very much for your help.
    >
    > With your help with this, i will finish up my report automation and it
    > will save me at least 4hrs a week.
    >
    > Thanks!
    >
    >
    > --
    > Excel_Newbie
    > ------------------------------------------------------------------------
    > Excel_Newbie's Profile: http://www.excelforum.com/member.php...o&userid=28861
    > View this thread: http://www.excelforum.com/showthread...hreadid=486456
    >
    >


  3. #3
    Forum Contributor
    Join Date
    03-03-2005
    Posts
    315
    To copy data from Range("a1:bm500") in WorkBook1.Sheets("A") to WorkBook2.Sheets("C"):


    Sub CopyWkBookToWkBook()

    set SourceBk=WorkBooks("Book1")
    set DestinBk=WorkBooks("Book2")

    SourceBk.Range("a1:bm500").Copy DestinBk.Range("a1")

    End Sub


    David.

  4. #4
    Forum Contributor
    Join Date
    03-03-2005
    Posts
    315
    Whoops! Incomplete referencing now rectified.

    To copy data from Range("a1:bm500") in WorkBook1.Sheets("A") to WorkBook2.Sheets("C"):


    Sub CopyWkBookToWkBook()

    set SourceBk=WorkBooks("Book1").Sheets("A")
    set DestinBk=WorkBooks("Book2").Sheets("C")

    SourceBk.Range("a1:bm500").Copy DestinBk.Range("a1")

    End Sub


    David.

+ 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