![]() |
Reset public variable
Hi,
Do you know how to reset public variables at the beginning of macro without using i = 0, j = 0 , ... Thanks, -- Alex St-Pierre |
Reset public variable
That is the way, why would you want another way?
-- HTH Bob Phillips (remove nothere from email address if mailing direct) "Alex St-Pierre" wrote in message ... Hi, Do you know how to reset public variables at the beginning of macro without using i = 0, j = 0 , ... Thanks, -- Alex St-Pierre |
Reset public variable
I have public variable because I use userform. When I restart macro.. all
variables are resets except public variable.. I have a lot of public variables and I don't want to write all because I try to have the simple text as possible. -- Alex St-Pierre "Bob Phillips" wrote: That is the way, why would you want another way? -- HTH Bob Phillips (remove nothere from email address if mailing direct) "Alex St-Pierre" wrote in message ... Hi, Do you know how to reset public variables at the beginning of macro without using i = 0, j = 0 , ... Thanks, -- Alex St-Pierre |
Reset public variable
Alex,
Try placing an End statement at the end of your macro. For example Option Explicit Public i As Integer Public Sub Test() i = i + 1 MsgBox i End ' Try this with and with out this End statement End Sub Without i retains its value from run to run. With it i is reset to 0 everytime you run the macro. *** Sent via Developersdex http://www.developersdex.com *** |
Reset public variable
Thanks,
It works good with End! I had the same problem with a userform. In a macro, I only disabled button and when I restrart, the form is not reset. I use Unload userform1 to reset the form. Does the End statement can also reset a form ? -- Alex St-Pierre "Edward Ulle" wrote: Alex, Try placing an End statement at the end of your macro. For example Option Explicit Public i As Integer Public Sub Test() i = i + 1 MsgBox i End ' Try this with and with out this End statement End Sub Without i retains its value from run to run. With it i is reset to 0 everytime you run the macro. *** Sent via Developersdex http://www.developersdex.com *** |
Reset public variable
Alex,
Depends on where the user form gets its values from. If from a ControlSource then no. Be careful in placement of the End statement. Its like saying no matter where I am in the execution of the macro stop everything and exit. *** Sent via Developersdex http://www.developersdex.com *** |
All times are GMT +1. The time now is 07:01 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com