Paste method fails when using template

knobblywobbly

New Member
Joined
Sep 28, 2011
Messages
4
Hi everyone,

I'm having a macro problem in Excel 2003 and wondered if you would be able to help me please? I'm copying some data from a worksheet, creating a new worksheet then pasting the data I copied into the new sheet. My code for this is below which works perfectly:

<STYLE>.alt2 font {font: 11px monospace !important;color: #333 !important;}</STYLE>

Code:
Selection.Copy 
Sheets.Add 
ActiveSheet.Name = shname 
Range("a11").Select ActiveSheet.Paste


</PRE><!-- END TEMPLATE: bbcode_code -->However, the data needs quite a lot of formatting so I created a template with the required formatting and tried to use this template when creating the new worksheet. Here's the code I'm now trying to use:

<!-- BEGIN TEMPLATE: bbcode_code -->
<STYLE>.alt2 font {font: 11px monospace !important;color: #333 !important;}</STYLE>

Code:
Selection.Copy 
Sheets.Add Type:="C:\RR Files\format.xlt" 
ActiveSheet.Name = shname 
Range("a11").Select ActiveSheet.Paste


</PRE>
<!-- END TEMPLATE: bbcode_code -->The above copies the data, creates the new worksheet based on the template file, renames the sheet to whatever is in the variable "shname", selects "A11" but then fails when trying to paste the data. I get the error message "Paste method of worksheet class failed".
Do you know why, just by changing the worksheet template, it would stop me from pasting the data into the new sheet?

Thanks
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.

Forum statistics

Threads
1,224,590
Messages
6,179,754
Members
452,940
Latest member
rootytrip

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