I have a loop that adds userform controls to a collection.
As the collection is needed in multiple places, I shoved it in a module and call it when I need it.
This means that the collection is only in memory when it's needed, but it also means I'm running a loop every time I want to work with it.
I could have given the collection module level scope and created it the first time it was needed.
I would have run the loop once, but the collection would have persisted in memory.
I found that 32bit Excel has a memory limit of 1.75Gb (although this can be extended, and there's the 64bit version) and that VBA excel is single threaded.
It seems I should be prioritizing processor efficiency over memory efficiency unless I have a specific need to do otherwise. Not only will the application be faster, it's potentially more energy efficient.
Giving the collection module level scope opens it up to inadvertent changes.
Is there a way to create the collection once, but not give it module level scope?
Better yet, is there a way to do this where it's only in memory when it's needed?