My Excel file had a load of macros and now when I click Developer - Macros, they don't show up in the list, the list is empty. How do I fix?
Hi this has 100% worked for me in all situations, if it is a macro file (in my case at least).
Open the file in protected mode (usually I save it on the share network so it prompts me to "Enable Content"). You must make sure you're in protected mode so no macros/libraries are activated.
DON'T ENABLE CONTENT
Go to Developer, Visual Basic, then click on "Debug" and click on "Compile VBA Project".
Save the file -- > Close - - > Reopen.
I have seen this happen multiple times, and eventually found a fairly easy solution.
To first summarize the problem, we have an excel workbook with macros. After saving and latter reopening the workbook, the macros are no longer there. Even selecting alt F11 ,fails to show any macros, even though macros are enabled in trust center.
The solution which has worked for me each time is to simply do the following.
Copy the Excel file to a thumb drive, and then open on a different computer. When the file opens, you will see an option at the top of the worksheet to Enable Functions. Click yes. At this point you can click alt F11 to verify that your macros are there. Assuming they are (this has worked for me every time), simply save the file, and then save back to your original location. When you open the workbook yur macros will be visible.
Good luck, and keep Excelling.
An even easier solution that has also worked for me 100% of the time is to open the file normally, and instead of clicking “enable content,” use shortcut alt f11 to open the VBA window. You should see your macros, save the file and reopen and “enable content” should work fine.
Surprisingly easy way to get it back.
Without the file open, right click on it.
Click on RESTORE PREVIOUS VERSIONS
It'll give you a list of previous days copies. Just try opening one of the ones from a previous day that the macro worked. The missing macro appeared in one of those for me when I opened it.
I had this same issue, but I was not able to open the modules in the VBA editor. I solved it by emailing a copy to myself, then opening it from outlook (with macros disabled). Then I compiled the VBA and saved it. The macros are back :)
Related
I have a workbook in which I consolidate data from various CSV files. There are a number of macros in this file including ones to add new sheets to the file, which is on a shortcut key Ctrl+Shift+N. This has been working perfectly for many years. This morning the shortcut key does absolutely nothing. If I go to the Excel developer tab and click on the Macros button, the list of macros is empty. However, if I open VBA I can run the macro from there and it still works perfectly.
I run Office Professional Plus 2019 and it ran an update yesterday. Does anyone know of a new setting introduced that may hide the macros in Excel itself. Note that macros are enabled on this workbook.
Just for closure should someone else stumble across this. The problem was related to the specific file. It somehow got "partially" corrupted. Still worked and could fire macros from VBA IDE as well as linked buttons, just not with shortcut keys as macros not "visible" in Excel view. File degraded further to a point where it could no longer save.
I have a spreadsheet stored in a central server at work with several macros in it. When I click on Developer-->Macros, the list of macros has disappeared, and the "create" button remains greyed out even when I type in a new macro name. The macros still appear in the "Module" list but clicking on them brings up a blank window.
However, when I make a copy of the file, paste it to my desktop, and rename it, the macros reappear.
In a final bizarre twist, when I then copy and paste that newly renamed file back to the work server, the macros disappear all over again.
Anyone have any idea what might be going on? My usual bag of tricks has failed me and I am close to restoring the file to a previous date.
In Excel, when opening the list of macros, there are some invalid entries. How to get rid of them?
Background:
I have an extended VBA library, containing a lot of UDFs and subs. I have added descriptions for UDFs using macro options. Maybe i created these invalid entries accidently in the past by a sub, which parses my code modules and generates descriptions for UDFs if this is provided via comments in the code module. This works fine now.
The invalid entries are actually the names of UDFs which do not exist anymore. They should not have appeared unter macros at any time, but again, maybe I messed up in the past.
I also would like to add some description to macros that do exist - but apparently that is only possible for UDFs?
Clarifications:
There is only this one workbook open. These are not macros of a different workbook. I selected "This Workbook only" for list of macros anyway.
There are no addins.
In VBE under Macros these invalid entires do NOT appear.
In Excel, under Developer Tools->Macros they DO appear.
In Excel, under Developer Tools->Macros, I can not edit or delete or execute these entries. Delete is greyed out, edit and execute lead to a popup error saying: "Der Bezug ist ungültig."
If you are referring to the Macro dialog that opens when clicking View > Macros, then note that there is a drop-down with which you can filter to show macros from a particular workbook only.
Use this to find where the "invalid" macros live, then edit that workbook and handle the macros from there (fix them or remove them).
The Macro dialog box that opens from the Developer tab lists all macros in "All open workbooks" by default. In the dropdown that shows this selection you can select to show macros in only a specific workbook. The reverse of this coin is that you can know exactly where any listed macro is located.
There are buttons to the right of the list which allow you to Edit or Delete any of the listed macros. The Edit button will take you to the module where the macro is stored.
There is also an Options button. When you click that another dialog box opens where you can set shortcuts as well as add a description. You can add a description to any listed macro, whether it's used as UDF or otherwise.
I wonder what would happen if a description exists for a macro that has been deleted. If such a situation is supported by Excel pressing the Delete button should rectify it.
I found an answer on microsoft.com:
https://answers.microsoft.com/en-us/msoffice/forum/msoffice_excel-mso_winother-mso_2016/cannot-delete-macros/8e9072ae-ad95-49cb-952c-3a50b746d0d2
So it appears my workbook got somehow "corrupted". As I said, I did play with it quite a bit during development. So what I did to fix it:
Export all code modules.
Save workbook as .xlsx under a different name.
Open this cleaned xlsx and save it as xlsm again.
Imported all code modules into this cleaned xlsm.
Manually copied code in worksheet from corrupted version to clean version.
Now the macros are gone in the cleaned version.
I've never been able to find the Personal.xlsb workbook. I've looked in the XLStart folder, it does not show in my VBA project explorer, and I don't know what to do. I went into my C:\Users...\AppData\Roaming\Microsoft\Excel\XLSTART
folder and just made a dummy xlsb. Can anyone think of any negative consequences to having this?
I honestly just need a spot to store all my macros for easy referencing, as I currently just put them in workbooks I need them to work, and then back them up in some text file somewhere in a pretty rudimentary list. Any advice on that would also be nice.
Best,
George
Yes, you can just create it. As far as I know there are no negative consequences for doing so, as long as you:
- call the file Personal.xlsb
- put it in the Excel Startup path (which you can find by executing ? Application.StartupPath from the Immediate pane in VBA editor) - usually this would be the path you mention
- hide the file (View tab, Hide command)
You can alternatively get Excel to automatically create the file in the right place with the right name etc by just recording a dummy macro using the macro recorder and choosing to Store macro in: "Personal Macro Workbook".
https://support.office.com/en-us/article/Copy-your-macros-to-a-Personal-Macro-Workbook-aa439b90-f836-4381-97f0-6e4c3f5ee566
You can go to the tab 'View' in your ribbon. You click on 'unhide'.
There you should be able to unhide Personal.xlsb
If it's not there, it doesn't exist.
I created a custom ribbon tab on my Excel like Excel_app_v1.xlsm, and a button under this ribbon tab is connected to a macro. So when I click this button, the macro does some table importing applications.
The first strange thing is that I created this ribbon tab and the button for only this Excel file, but the ribbon tab and the button appear in all other Excel files, even if the original Excel file Excel_app_v1.xlsm is not open.
The second problem is that I created a second version of my previous Excel file with "Save-as" option. So the new Excel file is like Excel_app_v2.xlsm. When I click the button under the ribbon tab, it opens the first Excel file Excel_app_v1.xlsm, even if it is not open. I deleted the first Excel file, but then I got an error like "Couldn't find the Excel_app_v1.xlsm on the path".
So obviously the macro button under the customized ribbon tab is linked to the first Excel file, but I couldn't find the menu option to change this. I added ThisWorkbook before all the sheet expressions in the vba code, but it didn't solve the problem. The button-click is still trying to open the old excel file.
The VBA code is below. The button is linked to the Sub ImportTable. Firstly it asks the user if the user wants to continue with the process. It opens the previous Excel file right after clicking on the button, at the same time as the Message Box appears.
Sub ImportTable()
Application.ScreenUpdating = False
YearMonth = ThisWorkbook.Sheets("tab1").Cells(11, 2).Value
' The Macro button opens the previous Excel file before clicking Yes or No on the message box
answer = MsgBox("Warning! Brings the newest source file. You want to continue?", vbYesNo + vbQuestion, "")
If answer = vbYes Then
RunSASCodeViaBatFile ' Another Sub which runs bat file to run a SAS-code. But it doesn't matter. Because the problem happens before I click on Yes or No.
InsertSASFileIntoExcel
Else ' Nothing happens if clicking No on the Message Box
End If
End Sub
The clue to fixing this quickly was posted below by roncruiser, with one slight twist.
Everyone on the web seems to feel that PERSONAL.XLSB is the key here — nope. In fact, playing with that file only confounded me for even longer. Here's what I did instead:
Right click the Ribbon and select Customize The Ribbon;
Navigate to the offending macros that you've installed with buttons;
Find and click on Import/Export;
Export your custom buttons (the macros will go right along just fine);
Open that resulting file, and edit out the offending references to the other file that's causing you so much grief — example:
<mso:button idQ="x1:HideRows_0_EA10D6" label="HideRows" imageMso="_3DPerspectiveDecrease" onAction="!HideRows" visible="true"/>
I took out everything after idQ-"x1... up to the actual name of the macro. I also took out the same external reference found in onAction="... Take everything up to the bang mark.
Save this under whatever name you wish, but with the same extension (for my setup, it was called ExportedCustomizations.exportedUI (yes, that long an extension));
Repeat the first few steps here, but this time import your edited file.
Voila, all is golden.
No messing around with wiping out existing work and starting all over. Worked a charm for me, so a big tip o' The Hat to roncruiser for the clue.
Just to confirm what sumgain have write above.
It works perfectly just do as he said : remove the part after the "x1:" that refers to a specific workbook until the begining of the maccro's name.
example :
When you export your custom ribbon with the maccro attached to it it will be write like below :
idQ="x1:C:_FolderName_Filename.xlsm_Fill_Formulas_Cells"
THen you remove the part mentionned and it will become like that :
idQ="x1:Fill_Formulas_Cells"
Same for onAction keep only the Maccro Name
Then it will works perfectly as long as you the maccro's name in the workbook stay consistent if you modified the Macros name then you have to modified it in the exportedUI file.
Then when you will reload the new file you can check in the Excel Options customize ribbon on the customize button if you put the pointer on you will see "Maccro: Name of your maccro"
And not the path of the file the maccro was from.
No need to use custom UI editor or any other things such as personnal maccro at least for that and if you are not bother to have custom ribbon in all of your woorkbook.
As well it is obvious but still good to remind it, you need to have the maccro in the workbook this procedure is just there to call the maccro that are associate to the workbook, it doesn't contain the code of the maccro.
Cheers
Romain
Does this still work? I have done this in the past with success but can't seem to get it to work now.
I export the file, edit it and import it back in.
it appears to work, but when i close the Ribbon options pane, my custom buttons disappear.
Same exact thing happened to me. There's a way to get around this.
By default, when you create a macro in Excel and run that macro through a custom ribbon button, that ribbon button macro works only in the workbook that contains it.
To get around this and have the button macros work in all workbooks, you'll need to create a Personal Macro Workbook. Then any macros that you store in your personal workbook on a computer become available to you in any workbook whenever you start Excel on that same computer.
Create a Personal Macro Workbook
To get the same ribbon button macros to work on another computer, you'll need to copy the Personal Macro Workbook to another computer and store it in the XLSTART folder. The link above has all the information you'll need.
Note: Delete the old ribbon button macros. Make sure you create new ribbon button macros that reference the macros from your Personal Macro Workbook.