|
-
Jan 30th, 2019, 04:01 PM
#1
Thread Starter
Fanatic Member
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.
-
Jan 30th, 2019, 04:13 PM
#2
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
 
-
Jan 30th, 2019, 04:49 PM
#3
Thread Starter
Fanatic Member
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?
-
Jan 30th, 2019, 04:50 PM
#4
Thread Starter
Fanatic Member
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?
-
Jan 30th, 2019, 06:14 PM
#5
Fanatic Member
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

-
Jan 30th, 2019, 10:49 PM
#6
Thread Starter
Fanatic Member
Re: Copy Existing Worksheet to a new Worksheet and make it current
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|