Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

vba courses london - setting all variables zero

Forum home » Delegate support and help forum » Microsoft VBA Training and help » vba courses london - Setting all variables to zero

vba courses london - Setting all variables to zero

ResolvedVersion Standard

Peter has attended:
Excel VBA Intro Intermediate course

Setting all variables to zero

We were shown how to set individual variables to zero (or empty them in the case of string varibles), but is there any one line piece of code to set all variables to zero or remove all variables in memory.

Thanks

RE: setting all variables to zero

Hi Peter

If you mean you want to initialise all variables to zero when you create them, you can create one main variable and set it to zero, then for all the other variables you create you can reference the original variable, thus they will be initialised to the value held within the original variable.

In regards to removing all variables in memory you want to use a process called garbage collection. I am not familiar with the code for this in VBA, but in asp.net the command is GC.Cellect(). I will look into this in greater depth and get back to you.

Hope this helps

David

 

Training courses

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.

VBA tip:

Add A New Sheet at the end of the Workbook

To add a new sheet at the end of the workbook you need to count the sheets in the workbook using:

Sheets.Count

Then use this value as the rank of the sheet after which you want to add the new sheet:

Sheets.Add After:=Sheets(Sheets.Count)

View all VBA hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.1 secs.