Question on copy/paste while retaining cell format

jameslytle

New Member
Joined
Jul 30, 2018
Messages
21
I have tried this multiple ways until I am blue in the face and have not been able to solve it. I am trying to copy one worksheet and paste it into a new one. What I am doing is have a template worksheet that is used to create duplicate worksheets (as needed) that can be modified while retaining the template with no modifications.

Below is what I have so far. The lines that are remarked out is where I start to run into issues.

***************************
Sheets.Add.Name = "CharData_" & Me.CharLastText.Text
'Sheets(CharData_Template).Copy
'Sheets("CharData_" & Me.CharLastText.Text).Paste
Sheets.Add.Name = "CharSheet_" & Me.CharLastText.Text
'Sheets("CharSheet_Template").UsedRange.Copy
'Sheets("CharSheet_" & Me.CharLastText.Text).Paste
Sheets("CharData_" & Me.CharLastText.Text).Range("B2") = Me.CharFirstText.Text
Sheets("CharData_" & Me.CharLastText.Text).Range("B3") = Me.CharLastText.Text
Sheets("CharData_" & Me.CharLastText.Text).Range("B4") = Me.PlayFirstText.Text
Sheets("CharData_" & Me.CharLastText.Text).Range("B5") = Me.PlayLastText.Text
*********************************
What I am doing is using a UserForm to capture data and then creating the new worksheets from the templates to be able to place the data obtained from the UserForm. These templates have some formatting (i.e. cell size, Merged cells and others) that I need to keep in tact after the new worksheet is created.

Everytime I put in the remarked lines I get an error code and it will not copy the data. The one time I got it to copy the data to the new worksheet it did not retain the formatting from the cells. Additional information; I have tried the command "Paste =:xlpasteformat (or pasteall) and it still did not work.

Any help is appreciated.

Jim
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Sheets(CharData_Template).Cells.Copy Sheets("CharData_" & Me.CharLastText.Text).Cells
 
Upvote 0
Thanks for the response.

I actually just found out how to do it via a different method.

*************************
'Create new Character Data WorkSheet and copy template data to it.
Sheets("CharData_Template").Copy before:=Sheets("CharData_Template")
ActiveSheet.Name = "CharData_" & Me.CharLastText.Text
'Create new Character Sheet WorkSheet and copy template data to it.
Sheets("CharSheet_Template").Copy before:=Sheets("CharData_Template")
ActiveSheet.Name = "CharSheet_" & Me.CharLastText.Text
*************************

Once again. Thanks for the quick response.

Jim
 
Upvote 0

Forum statistics

Threads
1,224,900
Messages
6,181,631
Members
453,059
Latest member
jkevin

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