Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
Do you know how to reset public variables at the beginning of macro without using i = 0, j = 0 , ... Thanks, -- Alex St-Pierre |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 *** |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 *** |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 *** |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Public variable | New Users to Excel | |||
Public Variable | Excel Programming | |||
Public variable is reset after addin macro completes - thread/focus pblm? | Excel Programming | |||
Public/Procedure Variable | Excel Programming | |||
public variable | Excel Programming |