Share via

I have created a few macros that I want to delete. But I am unable to do so.

Anonymous
2024-02-03T17:50:05+00:00

I have created several macros that i want to delete. But i am unable to do so. Since I am new to Macros I first tried to simply delete the workbook or file in which I created them, but this did not work, because i could go to Developer and View them. When I tried to delete them, this message appeared "cannot edit a macro on a hidden workbook, unhide the workbook using the unhide command. I then went to Document Inspector and still was unable to unhide the workbook so i could delete the unwanted macros. I would appreciate your help. I am eighty-two so be patient.

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Andreas Killer 144.1K Reputation points Volunteer Moderator
    2024-02-03T20:35:46+00:00

    I am eighty-two so be patient.

    Alright, I give you a short overview what you're doing. :-)

    If you record a macro you'll see this window and if you open the dropdown you can see 3 options:

    Image

    I bet you recorded your macros to your Personal Macro Workbook, that is a special file. If you record a macro the first time to this file, it is created automatically by Excel. The file is named PERSONAL.XLSB and it is hidden and it is loaded automatically each time you start Excel.

    Don't be scared, that's normal.

    Open Excel

    Open a file or start with a new file, doesn't matter

    Right-click a sheet tab and choose "View code" and you see something like this:

    Image

    On the left side is the Project Explorer, it's like the Windows Explorer, but instead of drives you see the files that are loaded into Excel. Anything you see that has .XLAM as extension is an Excel AddIn, most of them are protected and if you try to see the codes you're asked for a password. On your system you might see more or less or other AddIns, also that's normal.

    Okay, it's no easy to see but now we are in the code module of Sheet1 of the VBAProject of the file Book1, this is obvious a new file because it has no extension.

    BTW, on the right side, where the cursor is, is the editor of the code module, here is the place for some special macros.

    Open the dropdown which shows (General) and you'll see Worksheet as option. Select it and you'll see that a code is generated automatically and the 2nd dropdown shows SelectionChange. If you open that dropdown you'll see a lot of options, select Change and another code is generated. Keep that in mind, beginners in particular often try to use these routines and place them in other modules where they don't work.

    Now to your issue, click on the + sign on the left of the PERSONAL.XLSB file till you see the modules and double-click one of them.

    Image

    As you can see I have only one module named "Module1" in my file and after the double-click the macros are shown on the right side in the editor. This kind of modules are regular modules, "normal" macros goes into such a module.

    You can remove just the VBA code and the macro is gone, but you can also delete the module. Right-click Module1 and choose "Remove Module1...", Excel asks you

    Image

    Say no, and the module and code is gone.

    Switch to Excel and close it and Excel asks you

    Image

    Click Save to save your PERSONAL.XLSB file, done.

    Any questions?

    Andreas.

    1 person found this answer helpful.
    0 comments No comments