PDA

View Full Version : retentive variable



ferrugo
09-23-2009, 05:48 AM
:) Hi everybody
(sorry about my poor english):dunno

recently i did a macro that copy a 2 dimension excel matrix
example: myarray(500,500)
and i use this information in others macros, but the problem is that,
this code take some time to do the copy, and every time i need a value of this matrix, "mayarray(500,500)", i need wait the macro copy all the excel matrix again, so i want a variable, better than a static variable, that in the end of the macro this variable store his value.

In other words, a kind of variable that non erase after a end of the macro. Static variables are erased when the code is over (if im right:doh:) .

So every time i need a information of this matrix, i dont need wait copy the matrix again.

Thanks Everybody:)

Bob Phillips
09-23-2009, 06:10 AM
Try a public variable, declare it before the code.

ferrugo
09-23-2009, 06:38 AM
thanks xld
but doesnt work
even public variable are erased in end of the macro...

Bob Phillips
09-23-2009, 06:49 AM
No they aren't.

ferrugo
09-23-2009, 07:13 AM
xld.... :rotlaugh:
yeah.... you are right....

Sorry about my mistake...:banghead: .... wt a shame....

Can you help me with 1 more doubt....
How can i copy a matrix??? (entire matrix)

like:

matrix1() = matrix2()

both are with (500, 500) dimension...??

thanks again...

Bob Phillips
09-23-2009, 07:34 AM
Just use




matrix2 = matrix1