+ Reply to Thread
Results 1 to 6 of 6

VBA copy values to newly created sheet problem

  1. #1
    Registered User
    Join Date
    06-02-2013
    Location
    Sydney
    MS-Off Ver
    Excel 2007
    Posts
    19

    VBA copy values to newly created sheet problem

    Hi guys,

    I'm trying to copy content of one sheet to newly created sheet. The copy&paste code I created using "record macro" option.
    Code below fails on the line "Sheets(wsName).Select" with error 400. (select method of class Range failed)
    Could you please write what's wrong with that?

    Thanks

    Please Login or Register  to view this content.

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: VBA copy values to newly created sheet problem

    Try:
    Please Login or Register  to view this content.
    Last edited by xladept; 07-01-2013 at 07:49 PM.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Registered User
    Join Date
    06-02-2013
    Location
    Sydney
    MS-Off Ver
    Excel 2007
    Posts
    19

    Re: VBA copy values to newly created sheet problem

    I get same error.
    Is there another way to copy & paste?
    I have tried this code below, but xlPasteColumnWidths does nothing, replacing it by xlPasteValues helps, but no format is copied over which is bad.
    Any ideas?

    Please Login or Register  to view this content.

  4. #4
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: VBA copy values to newly created sheet problem

    Try this:

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    06-02-2013
    Location
    Sydney
    MS-Off Ver
    Excel 2007
    Posts
    19

    Re: VBA copy values to newly created sheet problem

    Thanks, it worked. So I don't have to Select newly created sheet...

  6. #6
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: VBA copy values to newly created sheet problem

    You're welcome! No, the newly created sheet is always the active sheet.

    (Don't forget to mark this thread as solved.)

+ 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