Free old variables

J

Jeff

Hi,

I have a macro that I run am running - here is the problem.

I have an array of values that is populated in the macro. It is a public
variable and I cannot make it local. When I rerun the array keeps its old
values.

Question - is there anyway to zero out the array again - I was just using
the loop at the beginning of the macro
For i =1 to 100
array(i) =0
Next i

.... but is there a better way?

Thanks for your help
 
J

Jim Rech

Erase ArrayName

--
Jim
| Hi,
|
| I have a macro that I run am running - here is the problem.
|
| I have an array of values that is populated in the macro. It is a public
| variable and I cannot make it local. When I rerun the array keeps its old
| values.
|
| Question - is there anyway to zero out the array again - I was just using
| the loop at the beginning of the macro
| For i =1 to 100
| array(i) =0
| Next i
|
| ... but is there a better way?
|
| Thanks for your help
 
D

Dave Peterson

Maybe using Erase would work for you:


Dim myArray(1 To 100) As Long
Dim iCtr As Long
For iCtr = LBound(myArray) To UBound(myArray)
myArray(iCtr) = iCtr
Next iCtr
Erase myArray
 
Top