How to copy sheets in macro

Drfox3

New Member
Joined
Mar 15, 2011
Messages
7
I have a workbook with x number of sheets.
How do copy a sheet (from the existing workbook)to a new workbook and go to the next sheet in the original workbook in a macro?
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p> </o:p>
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
What do you mean by "existing workbook" ?
Does it mean the active workbook?

What sheet has to be copied?
Is it the active sheet?

Does the "new workbook" exist or does it need to be created?
What name should be assigned to the "new workbook" ?

What do you mean by "go to the next sheet in the original workbook" ?
Do you mean activate the sheet immediately following the active sheet - if so, what do you want to do with the next sheet?
 
Upvote 0
Good questions Boller. I should have been more specific.
What do you mean by "existing workbook" ?
Does it mean the active workbook?
Yes - this refers to the active workbook (The one that is currently open).

What sheet has to be copied?
Is it the active sheet?
The macro will start with the active sheet but once it has copied that sheet, it will go to the next sheet in the open workbook(copies sheet(1), then copies sheet(2))....

Does the "new workbook" exist or does it need to be created?
What name should be assigned to the "new workbook" ?
The new workbook will have to be created. If possible,
I would like the new workbook to have the same name as the worksheet(the worksheet that was copied). If not possible just name the first workbook created, "Book1", the next workbook created, "Book2" and so forth.

What do you mean by "go to the next sheet in the original workbook" ?
Do you mean activate the sheet immediately following the active sheet - if so, what do you want to do with the next sheet?
In this case, once sheet(1) has been copied to a new workbook, then the macro returns to the original workbook and copies the next sheet (sheet(2)). This continues until the last sheet in the original workbook is activated and copied.
Below is the code that I tried to set to do this but it errored out.

Dim j As Integer, k As Integer
j = Worksheets.Count
For k = 1 To j
With Worksheets(k)
Sheets(k).Select - would error here.
Application.CutCopyMode = False
Sheets(k).Copy
End With
Next k

Thanks, I could, sure, use some help on this!
 
Upvote 0

Forum statistics

Threads
1,224,574
Messages
6,179,628
Members
452,933
Latest member
patv

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top