The following code removes all macros from my workbook:
On Error Resume Next With ActiveWorkbook.VBProject For X = .VBComponents.Count To 1 Step -1 .VBComponents.Remove .VBComponents(X) Next X For X = .VBComponents.Count To 1 Step -1 .VBComponents(X).CodeModule.DeleteLines _ 1, .VBComponents(X).CodeModule.CountOfLines Next X End With On Error GoTo 0
However, I have a macro called Wind() which I do not want removed. The code above references the VB component by a number, X, but this value may vary for Wind() . Therefore, is it possible to reference the VB component by name, and if that name is equal to Wind() , then the VB component will not be removed?
Many thanks if anyone can help,