*******************
Sub DeleteAllLines() ' удаляет все что написано в Модуле1
With ThisWorkbook.VBProject.VBComponents("Module1").CodeModule
.DeleteLines 1, .CountOfLines
End With
End sub
*******************
Sub DeleteModule() ' удаляет сам Модуль1
Dim vbc As VBComponent
Set vbc = ThisWorkbook.VBProject.VBComponents("Module1")
ThisWorkbook.VBProject.VBComponents.Remove vbc
Set vbc = Nothing
End sub
*******************
Sub DeleteModule() ' удаляет весь макрос
Dim tmp As String
Dim vbc As VBComponent
Dim prj As VBIDE.VBE
Set prj = Excel.Application.VBE
For Each vbc In prj.VBProjects("NAME").VBComponents
If (vbc.Type = vbext_ct_MSForm Or vbc.Type = vbext_ct_StdModule Or vbc.Type = vbext_ct_ClassModule) And vbc.Name <> "Module2" Then
tmp = vbc.Name
prj.VBProjects("NAME").VBComponents.Remove vbc
tmp = ""
End If
Next vbc
Set prj = Nothing
End sub