Results 1 to 6 of 6

Thread: Copy Existing Worksheet to a new Worksheet and make it current

  1. #1

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

    Copy Existing Worksheet to a new Worksheet and make it current

    Hi,

    How do I copy "Sheet1" to a new worksheet and make that the currently dimmed worksheet to add to?
    Say Sheet6 exists, how do I create Sheet7?

    There are several posts on how to copy a sheet but I need copy a sheet to a new sheet number and make it the active sheet for input.

  2. #2
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,109

    Re: Copy Existing Worksheet to a new Worksheet and make it current

    This sure sounds like an Office question, so I moved the thread there. If you are wanting to do that in .NET, then I can move it back, though there isn't really a concept of an active sheet when it comes to a .NET program.
    My usual boring signature: Nothing

  3. #3

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

    Re: Copy Existing Worksheet to a new Worksheet and make it current

    I was guessing the active sheet was dimmed as:
    dim xlworksheet As Excel.Worksheet
    Is this not correct?

  4. #4

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

    Re: Copy Existing Worksheet to a new Worksheet and make it current

    I was guessing the active sheet was dimmed as:
    Dim xlworksheet As Excel.Worksheet
    Is this not correct?

  5. #5
    Fanatic Member
    Join Date
    Feb 2013
    Posts
    985

    Re: Copy Existing Worksheet to a new Worksheet and make it current

    This just creates a worksheet variable/object that you can use to store data
    Code:
    Dim xlworksheet As Excel.Worksheet
    you then need to store some data in it
    Code:
    'you can use activeworksheet but i prefer using the sheets codenames for good practice
    Set xlWorksheet = Sheet1
    as for as copying a sheet you can do something like this
    Code:
    'this is a very simple way but i dont think you can put the new sheet into a variable directly (i maybe wrong)
    Sheets(1).Copy After:=Sheets(1)
    
    'or this method is also straight forward, i added another variable
    dim xlnewsheet as excel.worksheet
    Set xlnewsheet = sheets.add()
    xlnewsheet.name = "NewSheet"
    
    Set xlWorksheet  = Sheets(1)
    xlworksheet.activate 'this displays the page on screen
    xlworksheet.copy
    xlnewsheet.activate
    xlnewsheet.paste
    there are various other methods all basically using variations of the code i just provided, test some out
    Yes!!!
    Working from home is so much better than working in an office...
    Nothing can beat the combined stress of getting your work done on time whilst
    1. one toddler keeps pressing your AVR's power button
    2. one baby keeps crying for milk
    3. one child keeps running in and out of the house screaming and shouting
    4. one wife keeps nagging you to stop playing on the pc and do some real work.. house chores
    5. working at 1 O'clock in the morning because nobody is awake at that time
    6. being grossly underpaid for all your hard work


  6. #6

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

    Re: Copy Existing Worksheet to a new Worksheet and make it current

    Thank you so much!

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