Try adding this code:
 

    With ActiveWorkbook.VBProject
        For x = .VBComponents.Count To 1 Step -1
            If (.VBComponents(x).Name = "Report") Then
                .VBComponents(x).CodeModule.DeleteLines _
                1, .VBComponents(x).CodeModule.CountOfLines
            End If
        Next x
    End With 

Paul
-----------------------------------------
“Do all the good you can,
By all the means you can,
In all the ways you can,
In all the places you can,
At all the times you can,
To all the people you can,
As long as ever you can.” - John Wesley
-----------------------------------------

 From: Rob Flott <robfl...@gmail.com>
>To: excel-macros@googlegroups.com 
>Sent: Thursday, June 26, 2014 5:33 PM
>Subject: $$Excel-Macros$$ How to remove vb code after you make a copy
>  
>
>
>My application allows the user to make a copy of a worksheet so it can be 
>viewed outside of the application.  The problem I have with this is the code 
>written to that specific worksheet. 
>
>Is there code I can include in the 'make copy' macro that would remove all VB 
>code associated to that sheet? 
>
>I appreciate any direction you can provide. 
>
>Thank you 
>
>Here is my current 'make copy' macro: 
>
>Sub MakeCopy()
>    Sheets("Report").Select
>    Sheets("Report").Copy
>    ActiveSheet.Unprotect
>    Application.ScreenUpdating = False
>    
>    ActiveSheet.Shapes.Range(Array("Button 1", "Button 2", "Button 3", _
>        "TextBox 12", "Group 6", "Group 9")).Select
>    Selection.Delete
>    
>    Rows("4:5").Select
>    Selection.Delete Shift:=xlUp
>    
>    Range("A2:A3").Select
>    Selection.Copy
>    Selection.PasteSpecial Paste:=xlPasteAllUsingSourceTheme, 
>Operation:=xlNone _
>        , SkipBlanks:=False, Transpose:=False
>    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks 
>_
>        :=False, Transpose:=False
>    Application.CutCopyMode = False 
>
>    Range("A1").Select 
>
>    Application.ScreenUpdating = True
>End Sub
>....................................... 
>And here is the code associated with the 'report' sheet: 
>
>Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
>'sorts the datarange based on selected column heading
>Application.ScreenUpdating = False 
>If ActiveCell.Address = "$F$7" Then Sheets("List").Range("A20").Value = "F:F"
>If ActiveCell.Address = "$G$7" Then Sheets("List").Range("A20").Value = "G:G"
>If ActiveCell.Address = "$H$7" Then Sheets("List").Range("A20").Value = "H:H"
>If ActiveCell.Address = "$I$7" Then Sheets("List").Range("A20").Value = "I:I"
>If ActiveCell.Address = "$J$7" Then Sheets("List").Range("A20").Value = "J:J"
>If ActiveCell.Address = "$K$7" Then Sheets("List").Range("A20").Value = "K:K" 
>
>Call BR_RnkH2L 
>
>Application.ScreenUpdating = True 
>End Sub
>
-- 
>Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s 
>=TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ 
>https://www.facebook.com/discussexcel
> 
>FORUM RULES
> 
>1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
>Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
>quick attention or may not be answered.
>2) Don't post a question in the thread of another member.
>3) Don't post questions regarding breaking or bypassing any security measure.
>4) Acknowledge the responses you receive, good or bad.
>5) Jobs posting is not allowed.
>6) Sharing copyrighted material and their links is not allowed.
> 
>NOTE  : Don't ever post confidential data in a workbook. Forum owners and 
>members are not responsible for any loss.
>--- 
>You received this message because you are subscribed to the Google Groups "MS 
>EXCEL AND VBA MACROS" group.
>To unsubscribe from this group and stop receiving emails from it, send an 
>email to excel-macros+unsubscr...@googlegroups.com.
>To post to this group, send email to excel-macros@googlegroups.com.
>Visit this group at http://groups.google.com/group/excel-macros.
>For more options, visit https://groups.google.com/d/optout.
>
>
>    

-- 
Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s 
=TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ 
https://www.facebook.com/discussexcel

FORUM RULES

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.
2) Don't post a question in the thread of another member.
3) Don't post questions regarding breaking or bypassing any security measure.
4) Acknowledge the responses you receive, good or bad.
5) Jobs posting is not allowed.
6) Sharing copyrighted material and their links is not allowed.

NOTE  : Don't ever post confidential data in a workbook. Forum owners and 
members are not responsible for any loss.
--- 
You received this message because you are subscribed to the Google Groups "MS 
EXCEL AND VBA MACROS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to excel-macros+unsubscr...@googlegroups.com.
To post to this group, send email to excel-macros@googlegroups.com.
Visit this group at http://groups.google.com/group/excel-macros.
For more options, visit https://groups.google.com/d/optout.

Reply via email to