+ Reply to Thread
Results 1 to 2 of 2

Copy data from a different workbook

  1. #1
    Registered User
    Join Date
    10-01-2007
    Posts
    23

    Copy data from a different workbook

    I am trying to create a macro, contained in a button, that will open up a separate workbook (book7.xls), copy a range of cells, and paste them in the workbook with the macro.

    I thought this would be fairly simple as it is no problem for me to copy data from a separate worksheet, but I am running into a problem while trying to select a range in a different workbook. Below is the code that I am running into the error with:

    Please Login or Register  to view this content.
    I get the error "Select method of Range class failed"

    However, what is bizarre is that when I try to model the code generated by the macro recorder, it is the same EXACT code;except that it works. Below is the macro recorder code to copy/paste special values from one book to another. If I model my code from the macro recorder and place it in a button, it does not work. Does anybody know how to open a separate book and select a range without getting the error I have above?

    Please Login or Register  to view this content.

  2. #2
    Registered User
    Join Date
    10-01-2007
    Posts
    23
    Edit: I figured out that I needed to declare each workbook as a Worksheet and use the object to select a range.

    However, I am still confused as to why simply copying/pasting the macro recorder code results in an error. Anyone have an answer to 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