View Single Post
 
Old 08-30-2023, 05:09 PM
Logit Logit is offline Windows 10 Office 2007
Expert
 
Join Date: Jan 2017
Posts: 591
Logit is a jewel in the roughLogit is a jewel in the roughLogit is a jewel in the roughLogit is a jewel in the rough
Default

Code:
Option Explicit

'Reference : "Microsoft Visual Basic For Applications Extensibility"

Sub RemoveSheetModule()
    Dim wb     As Workbook
    Dim md     As Module
    Dim str    As String
   
    Application.ScreenUpdating = False
        Set wb = Workbooks.Open(ThisWorkbook.Path & "\" & "URL Check - Copy.xlsm")
       
        For Each md In wb
            Select Case md.Name
                Case "Module1"
                    str = md.CodeName
                    With wb.VBProject.VBComponents(str).CodeModule
                        .DeleteLines 1, .CountOfLines
                    End With
                Case Else
            End Select
        Next md
       
        wb.Close True
    Application.ScreenUpdating = True
   
    MsgBox "Done...", 64
End Sub

Sub delModMacro()
Dim wb As Workbook
 Set wb = Workbooks.Open(ThisWorkbook.Path & "\" & "CommandButton.xlsm")
    With wb.VBProject.VBComponents("Module1").CodeModule   '<--- change to ThisWorkbook for that module

            .DeleteLines 1, .CountOfLines

    End With
    
 MsgBox "Done...", 64
End Sub
Reply With Quote