Public variables

  • Thread starter Thread starter johnny
  • Start date Start date
J

johnny

Hi, I need your help to solve a scope problem.

I want a variable that can be accessed in "ThisWorkBook", and other
Sheets.

I tried to create a public variable in "ThisWorkBook", but I got a
undefined error, when tried to use it at other sheets module....

Also, How can I create a procedure in "ThisWorkBook" and can be
accessed in other sheets.


Thanks for your help.

Johnny.
 
Put the Public variable in a standard module.
Code in all modules can then use it.

Place your procedure in a standard module and you can then
call it from any module ... Call MyOtherProcedure

If for some reason you must place the procedure in the ThisWorkbook
module, you can call it from another module with this syntax ...
Call ThisWorkbook.MyOtherProcedure
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)



"johnny"wrote in message
Hi, I need your help to solve a scope problem.
I want a variable that can be accessed in "ThisWorkBook", and other
Sheets.
I tried to create a public variable in "ThisWorkBook", but I got a
undefined error, when tried to use it at other sheets module....
Also, How can I create a procedure in "ThisWorkBook" and can be
accessed in other sheets.
Thanks for your help.
Johnny.
 
Put the Public variable in a standard module.
Code in all modules can then use it.

Place your procedure in a standard module and you can then
call it from any module ... Call MyOtherProcedure

If for some reason you must place the procedure in the ThisWorkbook
module, you can call it from another module with this syntax ...
Call ThisWorkbook.MyOtherProcedure
--
Jim Cone
San Francisco, USAhttp://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)

"johnny"wrote in message
Hi, I need your help to solve a scope problem.
I want a variable that can be accessed in "ThisWorkBook", and other
Sheets.
I tried to create a public variable in "ThisWorkBook", but I got a
undefined error, when tried to use it at other sheets module....
Also, How can I create a procedure in "ThisWorkBook" and can be
accessed in other sheets.
Thanks for your help.
Johnny.

Thanks a lot.
 
Back
Top