+ Reply to Thread
Results 1 to 4 of 4

Copy data from one worbook to another.

  1. #1
    Registered User
    Join Date
    10-31-2012
    Location
    Sheffield
    MS-Off Ver
    Excel 2007, 2010
    Posts
    8

    Copy data from one worbook to another.

    Can anybody help me with my code, I am trying to copy data from one workbook to another using this code;

    Dim wbCopy As Workbook
    Dim wsCopy As Worksheet
    Dim rngCopy As Range
    Dim wbPaste As Workbook
    Dim wsPaste As Worksheet
    Dim rngPaste As Range

    Set wbPaste = ActiveWorkbook
    Set wbCopy = Workbooks.Open("C:\Users\vmhost\Desktop\Sheet.xlsm") 'change path
    Set wsCopy = wbCopy.Worksheets("Call Details")
    Set rngCopy = wsCopy.Range("a5:aa5").EntireColumn
    Set wsPaste = wbPaste.Worksheets("Sheet2") 'paste to different sheet if needed
    Set rngPaste = wsPaste.Range("a1") 'change this if needed


    rngCopy.Copy
    rngPaste.PasteSpecial

    Workbooks.Application.CutCopyMode = False
    Workbooks("C:\Users\vmhost\Desktop\Sheet.xlsm").Close False
    End Sub

    The code stops at the rngPaste.PasteSpecial Line

    any ideas?

    Secondly, any ideas how I could copy only certain columns into a third sheet?

    Thanks

    Gary

  2. #2
    Forum Expert
    Join Date
    12-15-2009
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft Office 365
    Posts
    3,177

    Re: Copy data from one worbook to another.

    Try
    Please Login or Register  to view this content.
    see if that works

  3. #3
    Registered User
    Join Date
    10-31-2012
    Location
    Sheffield
    MS-Off Ver
    Excel 2007, 2010
    Posts
    8

    Re: Copy data from one worbook to another.

    Quote Originally Posted by JieJenn View Post
    Try
    Please Login or Register  to view this content.
    see if that works
    Hi,

    Thank for the reply, still get 1004 error.

    Gary

  4. #4
    Forum Expert
    Join Date
    12-15-2009
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft Office 365
    Posts
    3,177

    Re: Copy data from one worbook to another.

    Can you post your file?

+ 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. modify macro to copy values instead of copy and worbook instead of worsheet
    By sbab in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-11-2013, 08:43 AM
  2. [SOLVED] copy data from one tab to another tab from another worbook
    By marreco in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-28-2013, 06:08 PM
  3. Loop through Worksheet and copy data into a templated worbook.
    By DDmonk in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 03-22-2011, 12:06 PM
  4. Copy data from workbook, create new workbook, paste data to new worbook?
    By mpkavanagh in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-16-2011, 06:39 PM
  5. Copy paste from one worbook to another workbook
    By mmf in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-04-2008, 01:00 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