ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   send sub routine variable to global (https://www.excelbanter.com/excel-programming/378058-send-sub-routine-variable-global.html)

Nigel[_27_]

send sub routine variable to global
 
so in a subroutine, i set a variable in the middle of script, and
aftewards, i wanted to use that variable globally....can i take a
variable and set a global variable with it from inside a subroutine?


[email protected]

send sub routine variable to global
 
Hi
Declare the variable outside the sub at the top of the module, but
define it as you did inside the sub.
Then
Dim myVariable
at the top of the sub can be used inside that module.
Also
Public myVariable
at the top of the sub can be used inside the project

regards
Paul

Nigel wrote:

so in a subroutine, i set a variable in the middle of script, and
aftewards, i wanted to use that variable globally....can i take a
variable and set a global variable with it from inside a subroutine?



Bob Phillips

send sub routine variable to global
 
Make it a function and return that value as the function result to the
caller.

--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

"Nigel" wrote in message
ups.com...
so in a subroutine, i set a variable in the middle of script, and
aftewards, i wanted to use that variable globally....can i take a
variable and set a global variable with it from inside a subroutine?





All times are GMT +1. The time now is 05:25 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com