Adding a variable returns error

mikeymay

Well-known Member
Joined
Jan 17, 2006
Messages
1,644
Office Version
  1. 365
Platform
  1. Windows
I am trying to add a variable to a routine but VB won't let me add it and returns an 'Out of Memory' error and removes the variable.

Not entirely sure why it's doing this as I don't have a massive number of public or local variables declared and the module isn't especially large.

I am setting a lot of range variables to manipulate data and move around various sheets without having to activate the relevant sheets and I'm wondering of this is causing a problem. I have, as far as I can see, set all range variables to 'Nothing' when finished with, but when set to 'Nothing' some will be re-used again as part of a loop routine.


Thanks
 
This is frustrating - I can't even remove variables (currBudgetMonth1-12) to replace with the array Nories suggested.

Could it be something to do with a corrupted dll file somewhere? I have read this might be an issue with these errors?
 
Upvote 0

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Are you saying that the error occurs whilst adding the code, and not while running it?
 
Upvote 0
Yes. When I tried to add another variable (Dim variable as variable type) I get the out of memory messgae and removes the text I typed in :(
 
Upvote 0
Can you add code to a different module?
 
Upvote 0
I am just in the process of moving the code and the worksheets to a new workbook and this seems to be working. I moved the code into a new book and I could add code to it.

I'm thining maybe the file has somehow become corrupted but will let you know once I have moved everythign over and tested.
 
Upvote 0
Ok, I have moved all the code and the worksheets to a new file and this seems to have worked.

Thinking about it, I intially encountered an error where a file I was saving via the code had a folder & file name of more than 218 characters which it the limit apparently. After this I then started to encounter the out of memory problems.

I'm not sure if have the '&' character as part of string variables could be an issue as I have come across problems with this character before, and I am using this in some of the string variables.
 
Upvote 0
I was going to suggest a corrupt file but didn't want to be pessimistic.

I wouldn't think & being part of a string would be a problem, as long as it was meant to be in the string.
 
Upvote 0
The '&' character does cause an issue where a string variable that contains it is used to name a file, the '&' is removed from the file name when saving to a temp folder before being attahced to an email.

I have a work around to deal with this but thought it may have had something to do with it.
 
Upvote 0

Forum statistics

Threads
1,224,542
Messages
6,179,421
Members
452,913
Latest member
JWD210

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top