+ Reply to Thread
Results 1 to 7 of 7

Range Issue

  1. #1
    Registered User
    Join Date
    06-25-2009
    Location
    Scotland
    MS-Off Ver
    Excel 2007
    Posts
    14

    Range Issue

    Hi everyone,

    I was wondering if someone could help me.

    I have 3 workbooks, I have a sheet that will have a button on it that will run the code, when the button is pushed, data from another workbook will then copy to a 3rd workbook.

    Control.xls - Has the button, which will run the vba code.
    Source.xls - Has the data to be copied.
    Dest.xls - Were the data will be copied too.

    This is the code I have so far:
    Please Login or Register  to view this content.

    I get the error "Select method of Range class failed". Can someone tell me where I am going wrong?

    Thanks

    Any questions just ask.
    Last edited by JayWeb; 01-24-2010 at 07:15 AM.

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,485

    Re: Range Issue

    Hard to tell without knowing the values of LastRow and LastColumn.

    Try using the Cells method rather than converting column to a character.

    Please Login or Register  to view this content.
    Also no need to select.
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    06-25-2009
    Location
    Scotland
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Range Issue

    Thanks Andy, worked perfectly.

    I now have another problem though, when the data is being copied, it is copying cells from Control.xls and not Source.xls.

    I thought something like this would work but its doesnt, it still copies from Control.xls
    Please Login or Register  to view this content.

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,485

    Re: Range Issue

    Use objects rather than rely on the active ones.

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    06-25-2009
    Location
    Scotland
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Range Issue

    Thanks for taking the time to write that for me, although if I use your code I get the error "Named Argument Not Found"

    Please Login or Register  to view this content.
    Any Ideas?

  6. #6
    Registered User
    Join Date
    06-25-2009
    Location
    Scotland
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Range Issue

    bump, anyone?

  7. #7
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,485

    Re: Range Issue

    I couldn't check you actual code as I did not have example data files.
    I therefore assumed the code you posted was at least compiling if not running as expected.

    The problem is the Pastespecial arguments you posted are for a Range object. Where as they code suggested you where using a worksheet object.

    You need to make this change

    Please Login or Register  to view this content.

+ 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