View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
keepITcool keepITcool is offline
external usenet poster
 
Posts: 2,253
Default Copying sheets without code

try..

Sub CopySansCode()
Dim wsSrc As Worksheet
Dim wsDst As Worksheet
Set wsSrc = ActiveSheet
Set wsDst = Worksheets.Add
wsSrc.Cells.Copy wsDst.Cells(1)

End Sub

It does have some drawbacks..as not everything is transferred

comments/formats/shapes/objects etc ARE transferred
pagesetup is (obviously) NOT transferred

AND you may lose "globally defined" rangenames.
(which when you'd use copy on the sheet
would be translated to "local defined names"

but then again it may work well in your situation.



--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam

?B?TGVzIEdvcmRvbg==?= wrote in message
:

How can I move/copy a sheet into another workbook without taking the
code attached to the sheet with it?

In particular I have a menu that should only appear when a particular
worksheet is active. This is achieved through the activate and
de-activate events. When I copy the sheet to another workbook (through
code) the event handlers go with it (and crash since they can't find
the function).

Do I have to go into the module behind the copied worksheet and delete
the code?

Regards

Les