| re: VBA Variables Already Initialised
Thanks for your responses.
I do always use Option Explicit, so I always declare my variables and their data types. I had thought VBA always initialised to a default value, and that variables were cleared out after the program had finished. I'm surprised I'd have to do explicit clearing of variables.
They are Global variables however, which may have something to do with it. As far as I am aware, this is the only code that runs in this single spreadsheet, and I have no others open.
Interesting that you mention about break points, an additional side effect that occurred was that when I initially debugged the script, I placed break points. As you know, closing and re-opening Excel causes those break points to be cleared out.
Only when I did this as per my post, when I ran the code on re-opening, the code broke and went into debug mode at the points where the breakpoints were before I restarted the program. Even though I had not placed them the second time around.
Oddly enough, one of my colleagues has reported a similar problem with the break points when using VBA in Access.
For the time being, I ran the code and it worked, and unfortunately I have a deadline to meet, so for now I'm going to leave it. When I get the chance, I will come back to the file and see if the problem keeps on occurring still. If it does, I'll take some more time to look into this thoroughly. If I figure it out, I'll come back and post the resolution.
Thank you for your comments.
Regards,
Rob.
[Edit]: Typo.
|