+ Reply to Thread
Results 1 to 6 of 6

Need to Copy Columns from Previous Workbook to Newly Opened Workbook

  1. #1
    Registered User
    Join Date
    10-04-2012
    Location
    Panama City, Florida
    MS-Off Ver
    Excel 2010
    Posts
    43

    Need to Copy Columns from Previous Workbook to Newly Opened Workbook

    I use a macro to open the latest workbook in a folder; the code is listed below. I need to copy all of columns B:N in my original workbook and paste them into the newly opened workbook columns C:O. I've tried a few things but I keep getting "subscript out of range" errors. Do I need to set the new workbook to the active workbook? I'm puzzled.

    Please Login or Register  to view this content.
    Moderator's Edit: Use code tags when posting code. To do so in future, select your code and click on the # icon at the top of your post window.
    Last edited by arlu1201; 12-04-2012 at 03:52 PM.

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,167

    Re: Need to Copy Columns from Previous Workbook to Newly Opened Workbook

    Which line does it highlight when you get the error?
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Registered User
    Join Date
    10-04-2012
    Location
    Panama City, Florida
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: Need to Copy Columns from Previous Workbook to Newly Opened Workbook

    Quote Originally Posted by arlu1201 View Post
    Which line does it highlight when you get the error?
    It doesn't highlight any line or cell; the "waiting" cursor comes up until I close out the error box. I must be using the wrong code to copy the columns. The newly opened sheet automatically has the first sheet titled "Breakdown", and my original workbook has a sheet1 titled Sheet1, so I used the following code: Probably wrong.

    Please Login or Register  to view this content.
    Last edited by BYizz; 12-04-2012 at 04:21 PM.

  4. #4
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,167

    Re: Need to Copy Columns from Previous Workbook to Newly Opened Workbook

    Before running the macro, is the latest file already open? Or should the macro open the file?

  5. #5
    Registered User
    Join Date
    10-04-2012
    Location
    Panama City, Florida
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: Need to Copy Columns from Previous Workbook to Newly Opened Workbook

    Quote Originally Posted by arlu1201 View Post
    Before running the macro, is the latest file already open? Or should the macro open the file?
    Either would work, but I would prefer to have the macro open the file.

  6. #6
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,167

    Re: Need to Copy Columns from Previous Workbook to Newly Opened Workbook

    Try this -
    Please Login or Register  to view this content.
    It copies data from the original workbook which contains the macro to the file you open. It will copy the entire columns. If you need only the rows to be copied without the header, let me know. You need to tweak the code a little for that.

+ 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