View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Tushar Mehta Tushar Mehta is offline
external usenet poster
 
Posts: 1,071
Default Lifetime of VBA variables

What Jim Thomlinson wrote has a 'kinda...' to it.

Module level variables retain their values as long as the workbook is
open *and* there is no unhandled fault in the code.

Also known (documented?) is a bug wherein all global variables lose
their values when one programmatically adds (deletes? does something
else to?) a control in an userform. I suspect there are other cases
where module level variables are reset -- intentionally or otherwise.

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

In article ,
says...
Jim Thomlinson wrote:
They retain their value for as long as the workbook is open... The same is
true of static variables...


Thank you.

Alan Beban

"Alan Beban" wrote:


I use VBA with Excel; I do not use VB.

My Visual Basic User's Manual says that Module-level variables retain
their values while Visual Basic is running. Does that mean as long as
Excel is open? Or as long as an Excel workbook is open? Or something else?

Thanks,
Alan Beban