+ Reply to Thread
Results 1 to 7 of 7

Copy existing (hidden) worksheet and replace/overwrite existing worksheet in same workbook

  1. #1
    Forum Contributor
    Join Date
    03-19-2019
    Location
    Essex, England
    MS-Off Ver
    Office 365
    Posts
    110

    Copy existing (hidden) worksheet and replace/overwrite existing worksheet in same workbook

    Hi, thanks for looking.

    I am trying to create a macro that will copy an existing hidden worksheet named "Quality Report (2)" and replace an existing (Active) worksheet called "Quality report".

    I have searched and tried a few methods but they all just seem to paste it to a new workbook, or before/after a worksheet, I need to overwrite the active worksheet with an exact duplicate, formatting, formulas etc.

    Seems like it should be straight forward but I'm struggling.

    Any help is greatly appreciated.

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Copy existing (hidden) worksheet and replace/overwrite existing worksheet in same work

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Forum Contributor
    Join Date
    03-19-2019
    Location
    Essex, England
    MS-Off Ver
    Office 365
    Posts
    110

    Re: Copy existing (hidden) worksheet and replace/overwrite existing worksheet in same work

    Hi AlphaFrog

    Thanks for replying. This is giving me 'There is not enough Memory to complete this action" error and then runtime error '1004' - PasteSpecial method of Range class failed' on the line

    Sheets("Quality Report").Range("A1").PasteSpecial xlPasteAll

    I have restarted and closed all other applications, running 64 bit with 16gb Ram so shouldn't struggle with this, any idea's?

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Copy existing (hidden) worksheet and replace/overwrite existing worksheet in same work

    Try this...

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    03-19-2019
    Location
    Essex, England
    MS-Off Ver
    Office 365
    Posts
    110

    Re: Copy existing (hidden) worksheet and replace/overwrite existing worksheet in same work

    Hi AlphaFrog

    Thanks again but still not working. I still get the memory error and the runtime error 1004 - but this time it says

    'Copy method of range class failed'

    I'm thinking maybe as a clumsy workaround I could just copy 'Quality Report (2)' before the 'Quality Report' and delete the original, may be worth a go as overwriting the original seems a bit problematic.

    Unless you have any better ideas or know why the above is failing?

  6. #6
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Copy existing (hidden) worksheet and replace/overwrite existing worksheet in same work

    Quote Originally Posted by Funkymonkey0073 View Post
    I'm thinking maybe as a clumsy workaround I could just copy 'Quality Report (2)' before the 'Quality Report' and delete the original, may be worth a go as overwriting the original seems a bit problematic.
    Please Login or Register  to view this content.
    Last edited by AlphaFrog; 12-11-2020 at 08:16 AM.

  7. #7
    Forum Contributor
    Join Date
    03-19-2019
    Location
    Essex, England
    MS-Off Ver
    Office 365
    Posts
    110

    Re: Copy existing (hidden) worksheet and replace/overwrite existing worksheet in same work

    Thanks AlphaFrog, that worked perfectly.

    I wasn't suggesting you do that, but you certainly saved me a lot of time and effort and it's very much appreciated.

    Stuart

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Macro to copy a hidden worksheet to an existing workbook then rename.
    By namy77 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-23-2017, 12:43 PM
  2. Copy out to a new worksheet within an existing workbook
    By Gatewaya89 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-20-2016, 12:49 PM
  3. [SOLVED] VB coding for using userform to edit and overwrite an existing database/worksheet
    By KumarPK in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-13-2016, 11:10 AM
  4. [SOLVED] Overwrite or Replace existing Worksheet with VBA
    By Davidp06 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-17-2014, 07:48 PM
  5. Replies: 11
    Last Post: 11-04-2013, 04:32 PM
  6. Replies: 3
    Last Post: 10-14-2013, 03:06 PM
  7. [SOLVED] Copy worksheet from one WB to another, overwrite existing worksheet with same CodeName
    By Renns in forum Excel Programming / VBA / Macros
    Replies: 22
    Last Post: 08-31-2012, 10:30 AM

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