Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 413
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 391
Default 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
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
code in module A to not execute a Worksheet_SelectionChange sub of another module Jack Sons Excel Discussion (Misc queries) 4 December 11th 05 11:52 PM
copying vba code to a standard code module 1vagrowr Excel Discussion (Misc queries) 2 November 23rd 05 04:00 PM
Reference Addin Module from sheet code zSplash Excel Programming 2 April 19th 04 06:35 PM
Write VBA code into a sheet module using VBA quartz Excel Programming 0 January 20th 04 08:01 PM
Variable from a sheet module in a class module in XL XP hglamy[_2_] Excel Programming 2 October 14th 03 05:48 PM


All times are GMT +1. The time now is 11:06 PM.

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

About Us

"It's about Microsoft Excel"