Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default macro for adding copy of worksheet

hi

i need to create copy of a standard template worksheet and then add
data to it
i have done the data part, but for some reason i cant seem to get the
code for creating a copy of my standard template worksheet

here is what i am doing:

Dim tosheet as Worksheet
Dim copysheet As Worksheet
Set copysheet = current.Worksheets("PC J12-1")
Set tosheet = copysheet.Copy

Now, my compiler complains: "expression or object expected" when it
encounters the Copy function. I don't understand what it wants,
because according to Microsoft's library, this should work. Can
someone suggest a solution to this? Or another better way of creating
a copy of an existing worksheet?

Thanks in advance.

Gobind

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default macro for adding copy of worksheet

It depnds on where you want the copy.

To keep it in the current workbook

copysheet.Copy Befo=Sheets(1)
Set tosheet = ActiveSheet

To move it to a new workbook

copysheet.Copy
Set tosheet = ActiveSheet

HTH,
Bernie
MS Excel MVP


"Gobind" wrote in message
oups.com...
hi

i need to create copy of a standard template worksheet and then add
data to it
i have done the data part, but for some reason i cant seem to get the
code for creating a copy of my standard template worksheet

here is what i am doing:

Dim tosheet as Worksheet
Dim copysheet As Worksheet
Set copysheet = current.Worksheets("PC J12-1")
Set tosheet = copysheet.Copy

Now, my compiler complains: "expression or object expected" when it
encounters the Copy function. I don't understand what it wants,
because according to Microsoft's library, this should work. Can
someone suggest a solution to this? Or another better way of creating
a copy of an existing worksheet?

Thanks in advance.

Gobind



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding a copy of an open window to an excel worksheet Jane Excel Worksheet Functions 3 November 30th 09 04:38 PM
Adding macro code to a new worksheet [email protected] Excel Programming 4 March 5th 07 02:52 AM
Adding Macro to Button on WOrksheet Barb Reinhardt Excel Discussion (Misc queries) 1 January 21st 06 02:29 PM
Dynamically adding a macro to a new worksheet Fred Russell Excel Programming 4 September 11th 05 10:31 PM
How? Macro to copy range to new worksheet, name new worksheet, loop Repoman Excel Programming 9 October 9th 03 01:45 PM


All times are GMT +1. The time now is 11:08 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"