I want to auto delete all VBA modules present in personal workbook, I am trying below code but this is showing an error 9 saying "subscript out of range " Please help me to solve this error
Sub deletemodule()
Dim vbCom As Object
Dim i As Integer
For i = 2 To 10
On Error GoTo abc
Set vbCom = Application.VBE.ActiveVBProject.VBComponents
vbCom.Remove vbComponent:=vbCom.Item("Module" & i)
Next
abc:
End Sub
Thanks in advance