VBA memory does not clear after closing workbook

Copper Contributor

Hi,

 

I have an issue with the memory in VBA not clearing whenever I close down a workbook. I am using Office 365. This is a rather new issue that I only had for a few weeks. In other words this is happening to workbooks that previously didn't have the issue. To add to the enigma it only happens on some of my computers while others don't have the problem. I am using the excactly same workbooks on different computers (using OneDrive) and only seeing the problem on some of the computers while others are just fine.

 

What happens in detail is that I open an xlsm workbook containing macros. I run a macro and close the workbook again. Now I still see the VBA project of the closed workbook in the VBA Editor with all the modules and code even though the workbook is closed. Usually this would of course have been cleared when the workbook containing the VBA project was closed.

 

Could you please help me resolve this issue?

 

Thank you in advance. 

4 Replies

@SrednaNova 

Do all PCs have the same macro settings in Excel?

This could be an issue when different Office versions access the file.

 

At the same time, please check whether clicking the "Reset" button in the "Debug" toolbar helps. this also deletes all static and project-wide variables. Running the VBA END command in a macro should have a similar effect. However, the macros and user forms must then be restarted, just like after opening the file.

 

With that I would also know at the end, hope that this information could help you.

 

NikolinoDE

I know I don't know anything (Socrates)

@NikolinoDE 

 

Thank you very much for your answer.

 

All the PC's have the same macro settings.

Your remark about different Office versions made me look into this anyway though. I turns out there is a difference here.

I have 5 computers, 4 is on Windows 10 and 1 on Windows 11. Just for the record. The 5 versions of Excel are as follows:

- Version 2201 (Build 14827.20198)

- Version 2201 (Build 14827.20198)

- Version 2201 (Build 14827.20192)

- Version 2201 (Build 14827.20192)

- Version 2201 (Build 14827.20158)

 

The last on that is only on build 14827.20158 is the one that is working. It is also telling me that is has an update available. I suspect that if I update it then it would have the same problem, but of course I don't know for sure untill I try.

 

If this is a general bug in the new builds I would expect many people to experience it, but I have not been able to find anything on the problem by searching the internet.

 

Clicking the "Reset" button in the "Debug" toolbar does not help whether it is done prior to closing the workbook or after. 

Pls. try following. It would not solve the issue but may provide some info that may help further (a hit and trial thing) :-

Activate any of the modules of closed workbook which is still appearing in VBA project explorer.
Open immediate window (Ctrl+G).
Check the address of the file containing this module by typing below in the immediate window:-
? ThisWorkbook.FullName
Is it a success or error?
Try the command again by moving/deleting the closed workbook.

(You can also try running a ThisWorkbook.Close sub)
Hi Again,
Thank you for the help.
I figured out how to roll back to a previous version of Office. That solved the problem. For now at least.