Does Global/Public variable keeps record until next excel macro code? What is the best practice in cleaning variable?

Viewed 29

I am currently using a public variable ( WorkbookNameString ) for keeping records of what workbook I have collated (in which would keep 1 long text if I selected multiple workbook at the same time).

The problem is it keeps on adding up all the workbook names even though I ran 1 file at a time.

ex. Workbook1.xlsx, Workbook2.csv, Workbook3.xls, etc..

Instead of:

Workbook1.xlsx
Workbook2.csv
Workbook3.xls

But if I close excel and after running 1 workbook, It won't add up, it seems that variable was cleared after reopening.

If Global/Public retains its values after running a code, What's the best way to clear all my declared public variables?

0 Answers
Related