Hello,
I have a work book, in Excel 2010, that uses modules to build a spreadsheet template (Datasheet-C). I work off of Sheet1. When all said and done, I have a button, on Datasheet-C, that when clicked deletes all other sheets besides Datasheet-C, removes the code from Datasheet-C for the button, and deletes the button. I have looked online in many places, but cant seem to find some way to delete all modules too.
Here is the code I have right now, that I thought was going to delete all modules, but it just deletes the code in the Datasheet-C sheet.
I would like if possible to delete(remove) all the modules that are listed under modules. Many people are going to be using this, and some may not be very excel saavy.
I have a work book, in Excel 2010, that uses modules to build a spreadsheet template (Datasheet-C). I work off of Sheet1. When all said and done, I have a button, on Datasheet-C, that when clicked deletes all other sheets besides Datasheet-C, removes the code from Datasheet-C for the button, and deletes the button. I have looked online in many places, but cant seem to find some way to delete all modules too.
Here is the code I have right now, that I thought was going to delete all modules, but it just deletes the code in the Datasheet-C sheet.
Code:
Private Sub DelVBA_Click()
Dim ws As Worksheet
With ActiveWorkbook
For Each ws In .Worksheets
With .VBProject.VBComponents(ws.CodeName).CodeModule
.DeleteLines 1, .CountOfLines
End With
End Sub
I would like if possible to delete(remove) all the modules that are listed under modules. Many people are going to be using this, and some may not be very excel saavy.
Last edited: