Hey guys,
I'm getting an inexplicable memory error while trying to optimize my code.
My macro is pretty big and totally not optimized, but it shouldn't be exceeding the limits of this computer quite yet.
Even stranger so: the error only occurs when trying to close an unnecessary workbook, in an effort to clear memory!
The involved secondary workbook is used just to extract some array's of data.
In it, there are 4 variable ranges of data that I need to work with, like this:
Set xxwrng = variablerange1 in secondary workbook
Set xxxrng = variablerange2 in secondary workbook
Set xxyrng = variablerange3 in secondary workbook
Set xxzrng = variablerange4 in secondary workbook
After that I compare values in my main workbook against these ranges.
Then the secondary workbook has no more use.
Originally I close this workbook at the very end of my macro. => no memory issues!
But now I tried to optimize my code, by closing this unnecessary workbook right after the comparison.
This is when I get the insufficient memory error!
I tried: Erasing the arrays, setting their values to nothing etc etc.
Can anyone explain this one?
Any referral to a beginner VBA memory management resource would also be greatly appreciated.
Atm I just write line after line of code, without organizing it in any optimized way.
Thank you in advance!
I'm getting an inexplicable memory error while trying to optimize my code.
My macro is pretty big and totally not optimized, but it shouldn't be exceeding the limits of this computer quite yet.
Even stranger so: the error only occurs when trying to close an unnecessary workbook, in an effort to clear memory!
The involved secondary workbook is used just to extract some array's of data.
In it, there are 4 variable ranges of data that I need to work with, like this:
Set xxwrng = variablerange1 in secondary workbook
Set xxxrng = variablerange2 in secondary workbook
Set xxyrng = variablerange3 in secondary workbook
Set xxzrng = variablerange4 in secondary workbook
After that I compare values in my main workbook against these ranges.
Then the secondary workbook has no more use.
Originally I close this workbook at the very end of my macro. => no memory issues!
But now I tried to optimize my code, by closing this unnecessary workbook right after the comparison.
This is when I get the insufficient memory error!
I tried: Erasing the arrays, setting their values to nothing etc etc.
Can anyone explain this one?
Any referral to a beginner VBA memory management resource would also be greatly appreciated.
Atm I just write line after line of code, without organizing it in any optimized way.
Thank you in advance!