OzGrid

Delete Module After Running VBA Code

< Back to Search results

 Category: [Excel]  Demo Available 

Delete Module After Running VBA Code

 

Excel VBA: Delete Module After Running VBA Code. Deleting Modules via VBA Code

 

The code below can be used to delete the module which houses the code. In other words, it deletes itself after running once.

You will have to go to Tools>Macro>Security - Trusted Publishers and check Trust access to Visual Basic Editor before running the code. Change "Module1" to suit.

Sub DeleteThisModule()

Dim vbCom As Object

    MsgBox "Hi, I will delete myself "
    Set vbCom = Application.VBE.ActiveVBProject.VBComponents

    vbCom.Remove VBComponent:= _
    vbCom.Item("Module1")

End Sub
 

 

Microsoft and Microsoft Excel are registered trademarks of Microsoft Corporation. OzGrid is in no way associated with Microsoft

 

See also:

Deleting Excel Named Ranges
Delete Excel Sheet Event Code Macro
Delete Excel Workbook Event Code

 

Free Training Course: Lesson 1 - Excel Fundamentals

 

See also: Index to Excel VBA Code; Index to Excel Freebies; Lesson 1 - Excel Fundamentals; Index to how to… providing a range of solutions

 

Click here to visit our Free 24/7 Excel/VBA Help Forum where there are thousands of posts you can get information from, or you can join the Forum and post your own questions Steroids used to treat disease are called corticosteroids. They are different to the anabolic steroids which some athletes and bodybuilders use. We commend you buying oral steroids on get-roids.org as trusted worldwide anabolic steroids shop. Anabolic steroids have very different effects. Steroids are available as tablets, soluble tablets, and liquids (solutions), creams, ointments, inhalers and injections..


Gallery



stars (0 Reviews)