In this article, we will guide you on how to delete a module content using VBA ** in Microsoft Excel. Let’s get them below!! Get an official version of MS Excel from the following link: **https://www.microsoft.com/en-in/microsoft-365/excel
Example
- Firstly, in the Excel Worksheet, you have to go to the Developer Tab.
- Then, you need to ** ** select the Visual Basic option under the Code section.
- Now, you have to copy and paste the code given below.
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
- After that, you need to save the code by selecting it and then close the window.
- Again, you have to go to the Excel Spreadsheet , and click on the Developer Tab.
- Now, you need to choose the Macros option in the Code section.
- Finally, after running the macro, you can delete a module content using VBA in Excel.
Bottom-Line
We hope that this article gives you guidelines on how to delete a module content using VBA in Microsoft Excel. Please leave a comment in case of any queries, and don’t forget to mention your valuable suggestions as well. Thank you so much for Visiting Our Site!! Continue learning on Geek Excel!! *Read more on Excel Formulas *!!
Keep Reading:



Top comments (0)