#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Sheet code

Suppose I copy the entire workbook to another workbook...
How do I write the code for a button in the old workbook to delete the
sheet code for Sheets 1 and 6 of the new workbook?


---
Message posted from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 493
Default Sheet code

Take a look he

http://cpearson.com/excel/vbe.htm

In article ,
courtesio99 wrote:

Suppose I copy the entire workbook to another workbook...
How do I write the code for a button in the old workbook to delete the
sheet code for Sheets 1 and 6 of the new workbook?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Sheet code

but i dunno which one applies to my case. Which one enables me to delete
the sheet codes in the new workbook but does not do anything to my
original workbook?

Can u please enlighten me? Thanks!


---
Message posted from http://www.ExcelForum.com/

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Sheet code

I'm sorry but where do I include the codes found in cpearson?
Do i put the codes in a new module, in This Workbook, or a new class
module?


---
Message posted from http://www.ExcelForum.com/

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Sheet code

In a regular module/new module (in the vbe, insert module).

--
Regards,
Tom Ogilvy

courtesio99 wrote in message
...
I'm sorry but where do I include the codes found in cpearson?
Do i put the codes in a new module, in This Workbook, or a new class
module?


---
Message posted from http://www.ExcelForum.com/





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Sheet code

Do you really just want Sheets 1 to 6 or to remove all code. If the latter:

This is an adaptation of code written and posted by Jim Rech:

Sub RemoveAllCodeFromCopy()
Const vbext_ct_StdModule As Long = 1
Const vbext_ct_ClassModule As Long = 2
Const vbext_ct_MSForm As Long = 3
Const vbext_ct_Document As Long = 100

Dim VBComp As Object, AllComp As Object, ThisProj As Object
Dim ThisRef As Object, WS As Worksheet, DLG As DialogSheet
Dim ThisBook As Workbook
On Error Resume Next
Kill "C:\Data1\Backup.xls"
On Error GoTo 0
ThisWorkbook.SaveCopyAs "C:\Data1\Backup.xls"
Set ThisBook = Workbooks.Open("C:\Data1\Backup.xls")
Set ThisProj = ThisBook.VBProject
Set AllComp = ThisProj.VBComponents
For Each VBComp In AllComp
With VBComp
Select Case .Type
Case vbext_ct_StdModule, vbext_ct_ClassModule, _
vbext_ct_MSForm
AllComp.Remove VBComp
Case vbext_ct_Document
.CodeModule.DeleteLines 1, _
.CodeModule.CountOfLines
End Select
End With
Next
For Each ThisRef In ThisProj.References
If Not ThisRef.BuiltIn Then _
ThisProj.References.Remove ThisRef
Next
Application.DisplayAlerts = False
For Each WS In Excel4MacroSheets
WS.Delete
Next
For Each DLG In DialogSheets
DLG.Delete
Next
End Sub

--
Regards,
Tom Ogilvy

courtesio99 wrote in message
...
Suppose I copy the entire workbook to another workbook...
How do I write the code for a button in the old workbook to delete the
sheet code for Sheets 1 and 6 of the new workbook?


---
Message posted from http://www.ExcelForum.com/



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Sheet code

thanks


---
Message posted from http://www.ExcelForum.com/

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
Sheet Name Changes how do i code for that Sonic Excel Worksheet Functions 0 July 10th 07 08:58 PM
VB code to copy sheet format to another sheet ASU Excel Discussion (Misc queries) 12 August 10th 06 02:37 AM
Help with some sheet code Gareth[_3_] Excel Programming 7 November 27th 03 11:50 PM
unprotect sheet in code and make sheet visible peach255 Excel Programming 1 August 1st 03 03:28 AM
Help with some sheet code Gareth[_3_] Excel Programming 1 July 12th 03 04:10 PM


All times are GMT +1. The time now is 01:11 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"