Results 1 to 3 of 3

Thread: [RESOLVED] Name Range in Seperate .xls

  1. #1

    Thread Starter
    Hyperactive Member VB4fun's Avatar
    Join Date
    May 2003
    Location
    too far from Fiji
    Posts
    342

    Resolved [RESOLVED] Name Range in Seperate .xls

    I am trying to open a different .xls file and copy an area, then paste the area into the current spreadsheet.

    I have:
    Code:
    Workbooks.Open Filename:="Blah Blah Blah"
    Range("A2:G82").Select
    Selection.Copy
    However, when running this, I get:
    "Select method of Range class failed"

    What am I missing?
    Talk does not cook rice.
    -Chinese Proverb

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Name Range in Seperate .xls

    That's because you just opened the other workbook, and don't refer to it with the Range method. If you don't supply a workbook and sheet, the active ones are assumed (in this case, likely to be the sheet that was already visible).

    Try this instead:
    VB Code:
    1. Dim oWorkBook as WorkBook
    2.   Set oWorkBook = Workbooks.Open (Filename:="Blah Blah Blah")
    3.   oWorkBook.Sheets("[i]Sheet1[/i]").Range("A2:G82").Select
    4.   Selection.Copy

  3. #3

    Thread Starter
    Hyperactive Member VB4fun's Avatar
    Join Date
    May 2003
    Location
    too far from Fiji
    Posts
    342

    Re: Name Range in Seperate .xls

    Thought it was along that line...but wasnt sure how to do it.

    You Rock!

    Thanks!
    Talk does not cook rice.
    -Chinese Proverb

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width