Results 1 to 4 of 4

Thread: Copy Worksheet

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2006
    Location
    London, UK
    Posts
    817

    Copy Worksheet

    I have an Excel workbook with one sheet named "Template"
    I obviously want to use that template sheet to create new sheets.
    How do I copy that sheet to a new sheet?

    I've scoured google and it's killing me that I can't find an applicable answer.
    This question must have been asked and answered many times.

    Dim xlapp As Excel.Application, xlworkbook As Excel.Workbook, xlworksheet As Excel.Worksheet

  2. #2
    Fanatic Member Delaney's Avatar
    Join Date
    Nov 2019
    Location
    Paris, France
    Posts
    846

    Re: Copy Worksheet

    Hello,

    Have a look here and here

    regards
    The best friend of any programmer is a search engine
    "Don't wish it was easier, wish you were better. Don't wish for less problems, wish for more skills. Don't wish for less challenges, wish for more wisdom" (J. Rohn)
    “They did not know it was impossible so they did it” (Mark Twain)

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2006
    Location
    London, UK
    Posts
    817

    Re: Copy Worksheet

    Thanks Delany.

    Ended up using
    Code:
            xlworksheet = xlworkbook.Sheets("Sheet1") 'Set sheet to be copied 
            xlworksheet.Copy(Type.Missing, xlworkbook.Sheets(xlworkbook.Sheets.Count)) 'Copy as new sheet at end
            xlworksheet = xlworkbook.Sheets(xlworkbook.Sheets.Count) 'Set new sheet as one to work with

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2006
    Location
    London, UK
    Posts
    817

    Re: Copy Worksheet

    Thanks Delany.

    Ended up using
    Code:
            xlworksheet = xlworkbook.Sheets("Sheet1") 'Set sheet to be copied 
            xlworksheet.Copy(Type.Missing, xlworkbook.Sheets(xlworkbook.Sheets.Count)) 'Copy as new sheet at end
            xlworksheet = xlworkbook.Sheets(xlworkbook.Sheets.Count) 'Set new sheet as one to work with

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