Results 1 to 2 of 2

Macros to transfer specific data from one workbook to another

Threaded View

  1. #1
    Registered User
    Join Date
    09-10-2012
    Location
    United States
    MS-Off Ver
    excel 2010
    Posts
    3

    Macros to transfer specific data from one workbook to another

    Hello,

    This is my first post and also my first issue. Yippee! I am trying to create a way to automatically transfer data from one workbook to another. The source workbook has more data than I need in the end workbook. So, I am trying to be selective. I need this to be able to take the data below the row selected on workbook 1 and put it below the row selected on workbook 2. These sheets will end up being pretty large and a seamless addition of the data would make life much easier. I also have workbook 1 in a PDF form if there is an easy way to do this from a PDF form. I have started with the Macros and used the recorder to come up with this for the code.

    Sub ChecklisttoIOR()
    '
    ' ChecklisttoIOR Macro
    '
    ' Keyboard Shortcut: Ctrl+j
    '
        Selection.Copy
        Windows("Book2").Activate
        ActiveCell.Offset(-4, -6).Range("A1").Select
        ActiveSheet.Paste
        Windows("Book1").Activate
        ActiveCell.Offset(0, 1).Range("A1").Select
        Application.CutCopyMode = False
        Selection.Copy
        Windows("Book2").Activate
        ActiveCell.Offset(0, 1).Range("A1").Select
        ActiveSheet.Paste
        Windows("Book1").Activate
        ActiveCell.Offset(0, 1).Range("A1").Select
        Application.CutCopyMode = False
        Selection.Copy
        Windows("Book2").Activate
        ActiveCell.Offset(0, 8).Range("A1").Select
        ActiveSheet.Paste
        Windows("Book1").Activate
        ActiveCell.Offset(0, 1).Range("A1").Select
        Application.CutCopyMode = False
        Selection.Copy
        Windows("Book2").Activate
        ActiveCell.Offset(0, -2).Range("A1").Select
        ActiveSheet.Paste
        Windows("Book1").Activate
        ActiveCell.Offset(0, 1).Range("A1").Select
        Application.CutCopyMode = False
        Selection.Copy
        Windows("Book2").Activate
        ActiveCell.Offset(0, 3).Range("A1").Select
        ActiveSheet.Paste
        Windows("Book1").Activate
        ActiveCell.Offset(0, 3).Range("A1").Select
        Application.CutCopyMode = False
        Selection.Copy
        Windows("Book2").Activate
        ActiveCell.Offset(0, -6).Range("A1").Select
        ActiveSheet.Paste
        Windows("Book1").Activate
        ActiveCell.Offset(0, 1).Range("A1").Select
        Application.CutCopyMode = False
        Selection.Copy
        Windows("Book2").Activate
        ActiveCell.Offset(0, 7).Range("A1").Select
        ActiveSheet.Paste
        Windows("Book1").Activate
        ActiveCell.Offset(0, 1).Range("A1").Select
        Application.CutCopyMode = False
        Selection.Copy
        Windows("Book2").Activate
        ActiveCell.Offset(0, -5).Range("A1").Select
        ActiveSheet.Paste
        Windows("Book1").Activate
        ActiveCell.Offset(0, 1).Range("A1").Select
        Application.CutCopyMode = False
        Selection.Copy
        Windows("Book2").Activate
        ActiveCell.Offset(0, 1).Range("A1").Select
        ActiveSheet.Paste
        Windows("Book1").Activate
        ActiveCell.Offset(0, 1).Range("A1").Select
        Application.CutCopyMode = False
        Selection.Copy
        Windows("Book2").Activate
        ActiveCell.Offset(0, 1).Range("A1").Select
        ActiveSheet.Paste
        Windows("Book1").Activate
        ActiveCell.Offset(0, -7).Range("A1").Select
        Application.CutCopyMode = False
        Selection.Copy
        Windows("Book2").Activate
        ActiveCell.Offset(0, 2).Range("A1").Select
        ActiveSheet.Paste
        Windows("Book1").Activate
        ActiveCell.Offset(0, 4).Range("A1").Select
        Application.CutCopyMode = False
        Selection.Copy
        Windows("Book2").Activate
        ActiveCell.Offset(0, 1).Range("A1").Select
        ActiveSheet.Paste
        Windows("Book1").Activate
        ActiveCell.Offset(0, 7).Range("A1").Select
        Application.CutCopyMode = False
        Selection.Copy
        Windows("Book2").Activate
        ActiveCell.Offset(0, 1).Range("A1").Select
        ActiveSheet.Paste
        Windows("Book1").Activate
        ActiveWindow.ScrollColumn = 2
        ActiveWindow.ScrollColumn = 3
        ActiveWindow.ScrollColumn = 4
        ActiveWindow.ScrollColumn = 5
        ActiveWindow.ScrollColumn = 6
        ActiveWindow.ScrollColumn = 7
        ActiveWindow.ScrollColumn = 8
        ActiveWindow.ScrollColumn = 9
        ActiveCell.Offset(0, 10).Range("A1").Select
        Application.CutCopyMode = False
        Selection.Copy
        Windows("Book2").Activate
        ActiveCell.Offset(0, 1).Range("A1").Select
        ActiveSheet.Paste
        Windows("Book1").Activate
        ActiveCell.Offset(0, -1).Range("A1").Select
        Application.CutCopyMode = False
        Selection.Copy
        Windows("Book2").Activate
        ActiveCell.Offset(0, 1).Range("A1").Select
        ActiveSheet.Paste
        Windows("Book1").Activate
        ActiveCell.Offset(0, -1).Range("A1").Select
        Application.CutCopyMode = False
        Selection.Copy
        Windows("Book2").Activate
        ActiveCell.Offset(0, 3).Range("A1").Select
        ActiveSheet.Paste
        Windows("Book1").Activate
        ActiveCell.Offset(0, 4).Range("A1").Select
        Application.CutCopyMode = False
        Selection.Copy
        Windows("Book2").Activate
        ActiveCell.Offset(0, -1).Range("A1").Select
        ActiveSheet.Paste
        Windows("Book1").Activate
        ActiveCell.Offset(0, -5).Range("A1").Select
        Application.CutCopyMode = False
        Selection.Copy
        Windows("Book2").Activate
        ActiveCell.Offset(0, 2).Range("A1").Select
        ActiveSheet.Paste
        ActiveWindow.ScrollColumn = 2
        ActiveWindow.ScrollColumn = 3
        ActiveWindow.ScrollColumn = 4
        ActiveWindow.ScrollColumn = 5
        ActiveWindow.ScrollColumn = 6
        ActiveWindow.ScrollColumn = 7
        ActiveWindow.ScrollColumn = 8
        ActiveWindow.ScrollColumn = 7
        ActiveWindow.ScrollColumn = 6
        ActiveWindow.ScrollColumn = 5
        ActiveWindow.ScrollColumn = 4
        ActiveWindow.ScrollColumn = 3
        ActiveWindow.ScrollColumn = 2
        ActiveWindow.ScrollColumn = 1
    End Sub
    When I try to run the macro I get a run-time error '1004' and ActiveCell.Offset(-4, -6).Range("A1").Select is highlighted in the debugger.

    Any help would be appreciated.

    Thank you,
    John Petry
    Attached Files Attached Files
    Last edited by arlu1201; 09-10-2012 at 02:04 PM.

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