» Delete a module using VBA in Microsoft Excel
VBA macro tip contributed by Erlandsen Data Consulting offering Microsoft Excel Application development, template customization, support and training solutions
CATEGORY - Modules, Class Modules in VBA
VERSION - All Microsoft Excel Versions
When you want to delete a module by code, you can use the macro below:
Sub DeleteVBComponent(ByVal wb As Workbook, ByVal CompName As String)
' deletes the vbcomponent named CompName from wb
Application.DisplayAlerts = False
On Error Resume Next ' ignores any errors
wb.VBProject.VBComponents.Remove wb.VBProject.VBComponents(CompName)
' delete the component
On Error GoTo 0
Application.DisplayAlerts = True
End SubExample:
DeleteVBComponent ActiveWorkbook, "TestModule"
Book Store:
Recommended Books:
- Microsoft Word Version 2002 Step By Step (With CD-ROM)
- Seven Habits Of Highly Effective People
- The One Page Business Plan: Start With a Vision, Build a Company!
- Microsoft Office XP Introductory Concepts and Techniques
- Millionaire Real Estate Mentor : The Secrets of Financial Freedom through Real Estate Investing
- AWAKEN THE GIANT WITHIN : HOW TO TAKE IMMEDIATE CONTROL OF YOUR MENTAL, EMOTIONAL, PHYSICAL AND FINANCIAL
No comments have been submitted.

