Teach Microsoft Office
Online Video Tutorials for Microsoft Office
Microsoft Office Excel Macro

Delete a VBA Module From Excel

Bookmark and Share
Delete a VBA macro module from Excel with this macro. This macro allows you to fully remove a macro module from Excel. This is great when you need to quickly clean up your macros, vba, or just leftover modules in Excel. You do need to be careful not to delete a module that contains important code. This is a great macro and is very powerful.

To use this macro, you need to do two things. First, replace Module1 with the name of the actual module which you want to delete. If you wanted, you could include this in a loop in order to delete all modules from the workbook in Excel. Second, you need to enable access to the vba project object model - > In previous versions of Excel go to Tools > Macro > Security - Trusted Publishers check the box next to "Trust access to Visual Basic Editor". In Excel 2007 go to Office Button > Excel Options > Trust Center > Trust Center Settings > Macro Setting and check the box next to "Trust access to the VBA project object model".
Macro Installation Location: Module
Keywords: sort data sorting excel one column next subset adjacent data set table advanced
Excel Macro to Delete a VBA Module From Excel

Sub Delete_Module()
Dim vbCom As Object

Set vbCom = Application.VBE.ActiveVBProject.VBComponents

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

End Sub

 
Official PayPal Seal SSL Join TeachMsOffice.com on Facebook Follow TeachMsOffice.com on Twitter


Microsoft Office Tutorials | Office Tutorials - Excel Word PowerPoint | HD Tutorial Video Player Overview | About TeachMsOffice.com

TeachMsOffice.com provides HD Online Video Tutorials and Training for Microsoft Office programs such as Excel, Word, and PowerPoint. We use a specialized video player interface to teach a vast list of Microsoft Office Tutorials and we add new tutorials on a weekly or monthly basis.