ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   copying an existing sheet (https://www.excelbanter.com/excel-programming/432871-copying-existing-sheet.html)

thomas donino

copying an existing sheet
 
I have a macro that creates reports from a main sheet. I want to make the new
sheets it creates come from a template, ie a sheet i call template in the
current workbook. This will eliminate multiple copy and paste steps in the
current macro.

I recorded a macro that right clicks the sheet tab, copies and renames but
that doesn't work when run.

any thoughts?

Jacob Skaria

copying an existing sheet
 
'The below will copy the current sheet and rename
ActiveSheet.Copy After:=ActiveSheet
Set ws = ActiveSheet
ws.Name = "newname"

'The below will copy the current sheet to the end...and rename
ActiveSheet.Copy After:=Sheets(Sheets.Count)
Set ws = ActiveSheet
ws.Name = "newname"


If this post helps click Yes
---------------
Jacob Skaria


"thomas donino" wrote:

I have a macro that creates reports from a main sheet. I want to make the new
sheets it creates come from a template, ie a sheet i call template in the
current workbook. This will eliminate multiple copy and paste steps in the
current macro.

I recorded a macro that right clicks the sheet tab, copies and renames but
that doesn't work when run.

any thoughts?


Don Guillett

copying an existing sheet
 
have you tried


sheets("Template").copy
activesheet.name="newnamehere"

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"thomas donino" wrote in message
...
I have a macro that creates reports from a main sheet. I want to make the
new
sheets it creates come from a template, ie a sheet i call template in the
current workbook. This will eliminate multiple copy and paste steps in the
current macro.

I recorded a macro that right clicks the sheet tab, copies and renames but
that doesn't work when run.

any thoughts?



thomas donino

copying an existing sheet
 
thank you

"Jacob Skaria" wrote:

'The below will copy the current sheet and rename
ActiveSheet.Copy After:=ActiveSheet
Set ws = ActiveSheet
ws.Name = "newname"

'The below will copy the current sheet to the end...and rename
ActiveSheet.Copy After:=Sheets(Sheets.Count)
Set ws = ActiveSheet
ws.Name = "newname"


If this post helps click Yes
---------------
Jacob Skaria


"thomas donino" wrote:

I have a macro that creates reports from a main sheet. I want to make the new
sheets it creates come from a template, ie a sheet i call template in the
current workbook. This will eliminate multiple copy and paste steps in the
current macro.

I recorded a macro that right clicks the sheet tab, copies and renames but
that doesn't work when run.

any thoughts?



All times are GMT +1. The time now is 02:51 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com