How to clear memory to prevent “out of memory error” in excel vba?

后端 未结 7 2146
长发绾君心
长发绾君心 2020-11-27 18:50

I am running VBA code on a large spreadsheet. How do I clear the memory between procedures/calls to prevent an \"out of memory\" issue occurring?

Thanks

7条回答
  •  甜味超标
    2020-11-27 19:47

    Answer is you can't explicitly but you should be freeing memory in your routines.

    Some tips though to help memory

    • Make sure you set object to null before exiting your routine.
    • Ensure you call Close on objects if they require it.
    • Don't use global variables unless absolutely necessary

    I would recommend checking the memory usage after performing the routine again and again you may have a memory leak.

提交回复
热议问题