» Delete module content 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
charts and ThisWorkbook. In these modules you have to delete the content instead of the module itself:
Sub DeleteModuleContent(ByVal wb As Workbook, _
ByVal DeleteModuleName As String)
' deletes the contents of DeleteModuleName in wb
' use this if you can't delete the module
On Error Resume Next
With wb.VBProject.VBComponents(DeleteModuleName).CodeModule
.DeleteLines 1, .CountOfLines
End With
On Error GoTo 0
End Sub
Example:
DeleteModuleContent ActiveWorkbook, "Sheet1"
Book Store:
Recommended Books:
- Microsoft Windows XP Registry Guide
- H&R Block's Just Plain Smart(tm) Tax Planning Advisor: A year-round approach to lowering your taxes this year, next year and beyond
- Who Moved My Cheese? An Amazing Way to Deal with Change in Your Work and in Your Life
- Essentials of Investments with Standard & Poor's Educational Version of Market Insight + PowerWeb + Stock Trak Coupon
- Microsoft Word Version 2002 Inside Out
- Absolute Beginner's Guide to Microsoft Office Excel 2003
No comments have been submitted.

