Thread: Static variable
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_3_] Bob Phillips[_3_] is offline
external usenet poster
 
Posts: 2,420
Default Static variable

You could save it to registry on closing, and read it from there on opening.
See SaveSetting and GetSetting in VBA help

--
__________________________________
HTH

Bob

"VBA beginner" wrote in message
...
How can I save the value of the variable so, that it keeps its value also
after the application has closed?

I have module, where I have:
Sub counting()
Static counter As Integer

counter = counter +1

End sub

But if I save and close the program, and open it again, the value of the
counter is again 0. Any suggestions to fix the problem?