Dear all,
In my VBA project I have a lot of codes...
But I want that in one code create a variable to use in another code.
For example:
sub code_1()
dim x as variant
set x = 10
end sub
sub code_2()
for i = x
.
.
.
end sub
How can I do this? And what I need to do for update de variable?
Thanks a lot!!!
André.
Dave Peterson - 29 Aug 2007 12:26 GMT
One way:
Option Explicit
Dim x as long 'this variable is visible to just this module
Public y as long 'this variable is visible to all modules
sub code_1()
x = 10 'no set required
end sub
sub code_2()
dim i as long
for i = x
...
next i
end sub
Another way is to pass the value between subroutines:
Option Explicit
sub code_1()
x = 10 'no set required
call code_2A(SomeVar:=x)
end sub
sub code_2a(SomeVar as long)
dim i as long
for i = SomeVar
...
next i
end sub
> Dear all,
>
[quoted text clipped - 25 lines]
>
> André.

Signature
Dave Peterson