Need help deleting 'ghost' macro

G

Guest

Guest
Thought I would try to learn to create/use macros - don't know what I did but apparantly I created something... went to delete it (toolsmacrosselected 'this workbook' and deleted) - but the beast still lives on - when opening workbook I get warning msg. about file contains macros ( disable/enable?)- but when I go to toolsmacrosetc. - no macros are displayed - how do I get rid of this? Thanking in advance - the users of the workbook freak when they see the warning message containg both the 'macro' and 'virus' words...
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Put this code in another workbook, then select the workbook containing 'ghost' macros and run the macro DeleteAllVBA. This code is from Chip Pearson's website. YOU MUST set a reference to the Microsoft Visual Basic for Applications Extensibility library before running (Tools, References and then check that library) otherwise you'll get an error.

http://www.cpearson.com/excel/vbe.htm

HTH,
D

Code:
Sub DeleteAllVBA()

Dim VBComp As VBIDE.VBComponent
Dim VBComps As VBIDE.VBComponents

Set VBComps = ActiveWorkbook.VBProject.VBComponents

For Each VBComp In VBComps
   Select Case VBComp.Type
      Case vbext_ct_StdModule, vbext_ct_MSForm, _
            vbext_ct_ClassModule
         VBComps.Remove VBComp
      Case Else
         With VBComp.CodeModule
            .DeleteLines 1, .CountOfLines
         End With
   End Select
Next VBComp

End Sub
 
Upvote 0

Forum statistics

Threads
1,213,560
Messages
6,114,309
Members
448,564
Latest member
ED38

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top