Public variables

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.
 
J

Jim Cone

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.
 
J

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top