+ Reply to Thread
Results 1 to 3 of 3

macro to copy columns from one workbook to another

  1. #1
    Registered User
    Join Date
    04-23-2008
    Posts
    50

    macro to copy columns from one workbook to another

    Hi,
    I have the code below which copies columns A:C from Book1 into Book2. However, it does not work when the Book1 is not open. I would like the macro to still work when the Book1 is closed. How can I solve this problem?

    Sub CopyColumnToWorkbook()
    Dim sourceColumn As Range, targetColumn As Range

    Set sourceColumn = Workbooks("Book1").Worksheets("Sheet1").Columns("A:C")
    Set targetColumn = Workbooks("Book2").Worksheets("Sheet1").Columns("A:C")

    sourceColumn.Copy Destination:=targetColumn
    End Sub

    Many thanks,

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2507 Win 11
    Posts
    24,917

    Re: macro to copy columns from one workbook to another

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Registered User
    Join Date
    04-23-2008
    Posts
    50

    Re: macro to copy columns from one workbook to another

    Please see the code in the attachement copy columns.txt

+ 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. Need to Copy Columns from Previous Workbook to Newly Opened Workbook
    By BYizz in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-06-2012, 06:33 AM
  2. Macro to copy entire columns with matching dates from another workbook
    By rocksan in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-28-2012, 01:23 PM
  3. Macro to copy and paste columns from one workbook to a new workbook
    By windcloud2 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-05-2012, 11:45 AM
  4. Copy columns from closed workbook to different columns in open workbook
    By jGLZa in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-04-2012, 11:03 PM
  5. Need macro to Concatenate columns in one workbook and copy to another workbook
    By capnhud in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-08-2010, 05:14 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