Im my example, I'm copying a range called 'Database' from
a sheet called 'main' into a new workbook...
Sub CopySheet()
Dim wb As Workbook
Dim Source As Range
Dim target As Range
Set Source = _
ThisWorkbook.Sheets("main").Range("Database")
Set wb = Workbooks.Add(xlWBATWorksheet)
With wb.ActiveSheet
Set target = .Range(.Range("A1"), _
.Cells(Source.Rows.Count, Source.Columns.Count))
End With
target.Value = Source.Value
End Sub
By just copying the values from the sheet rather than the
sheet itself, we avoid copying any code that is a
attached to the sheet
HTh
Patrick Molloy
Microsoft Excel MVP
-----Original Message-----
A routine runs, whereby the contents of a workbook are
copied
to a new workbook. This new workbook contains one single
worksheet. It has no standard modules, and the
Thisworkbook
module is empty. However, there is still code in the new
sheet's
Sheet module (specifically Worksheet_SelectionChange
Event
code).
I understand this cannot be deleted.
If that is the case, can I prevent it being copied into
the new
worksheet in the first place?
Regards.
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system
(
http://www.grisoft.com).
Version: 6.0.735 / Virus Database: 489 - Release Date:
06/08/2004
.