Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Sheet code module question
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Sheet code module question
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 . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
code in module A to not execute a Worksheet_SelectionChange sub of another module | Excel Discussion (Misc queries) | |||
copying vba code to a standard code module | Excel Discussion (Misc queries) | |||
Reference Addin Module from sheet code | Excel Programming | |||
Write VBA code into a sheet module using VBA | Excel Programming | |||
Variable from a sheet module in a class module in XL XP | Excel Programming |