» 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:
- Excel 2002 Power Programming with VBA
- Microsoft Windows XP Inside Out
- Microsoft Excel 2002 Simply Visual
- Millionaire Real Estate Mentor : The Secrets of Financial Freedom through Real Estate Investing
- Marketing Plans That Work, Targeting Growth and Profitability
- The South Beach Diet: The Delicious, Doctor-Designed, Foolproof Plan for Fast and Healthy Weight Loss
No comments have been submitted.


