💡 Source Code
'Microsoft Scripting Runtime - Don't forget to activate this library
Sub RemoveVBComps()
Dim vb As Object, vb_comp_name As String, i As Byte, k As Byte, _
d As New Scripting.Dictionary, dd As Variant
Cells.Clear
i = 1
On Error Resume Next
For Each vb In ThisWorkbook.VBProject.VBComponents
If vb.Type ▶= 1 And vb.Type ◀= 3 Then
If vb.Type = 1 Then
vb_comp_name = "Module"
ElseIf vb.Type = 2 Then
vb_comp_name = "Class Module"
ElseIf vb.Type = 3 Then
vb_comp_name = "UserForm"
End If
If Not d.Exists(vb_comp_name) Then
d.Add vb_comp_name, 1
Else:
d.Item(vb_comp_name) = d.Item(vb_comp_name) + 1
End If
Cells(i, 1) = vb_comp_name
Cells(i, 2) = vb.Name
ThisWorkbook.VBProject.VBComponents.Remove vb
i = i + 1
End If
Next vb
With [d1]
.Value = "THE NUMBER OF COMPONENTS REMOVED"
.Font.Bold = -1
.Interior.Color = vbYellow
End With
k = 3
For Each dd In d
Cells(k, 4) = dd
Cells(k, 5) = d.Item(dd)
k = k + 1
Next dd
Columns("A:D").AutoFit
End Sub
------------------------------------------------------------------------------------------
#excel
#msexcel
#msexceltutorial
#msexcelcourse
#vba
#vbatutorial
#excelvba
#fulltutorial
#excelvbatutorial
#microsoftexceltutorial
#tutorial
#exceltutorial
#advancedexcel
#advancedexceltraining
#tutor
#exceltutor
#exceltutoring
#exceltutoringonline
#onlineexceltutoring
#algorithm
#algorithms
#programming
#program
#script
#vbamacro
#vbamacros
#usingmacro
#veryuseful
#useful
#veryusefulmacro
#freeeducation
#freeprogramming
#freelancer
#excelfreelancer
#vbafreelancer
#freelanceservices
#vbcomponent
#vbcomponents
#visualbasiccomponent
#module
#classmodule
#class
#userform
#activatevbcomponent
#vbamodule
#vbaclassmodule
#vbauserform
#remove
#removecomponent
#removingvbcomponents
#selfdestruct
#selfdestruction
#selfdestructsystem
#veryusefulcode
#vbadefensesystem
#microsoftscriptingruntime
#scrrun
#dll
#runtime
#dictionary
#object
#earlybinding
#string
#byte
#variant
#vbatypes
#vbcomponenttype
#autofit
#excelautofit
#vbaautofit