ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Sharing Variables (https://www.excelbanter.com/excel-discussion-misc-queries/92404-sharing-variables.html)

CWillis

Sharing Variables
 
I give a variable a value in a macro inside a worksheet. I want it to be
available later in other macros in other worksheets and in "ThisWorkbook".
How do I do this?

Thanks.

Dave Peterson

Sharing Variables
 
How about just declaring that variable as Public in a General module?

CWillis wrote:

I give a variable a value in a macro inside a worksheet. I want it to be
available later in other macros in other worksheets and in "ThisWorkbook".
How do I do this?

Thanks.


--

Dave Peterson

Daniel CHEN

Sharing Variables
 
If you want the variable to be accessable in the same module, you can define
the variable (use dim statement) outside of all functions/procedures and put
it at the top of coding.

If you want the variable to be accessable in other modules, use public
statement.


--
Best regards,
---
Yongjun CHEN
==================================
- - - - www.XLDataSoft.com - - - -
Free Excel/VBA Tool & Training Material
==================================
"CWillis" wrote in message
...
I give a variable a value in a macro inside a worksheet. I want it to be
available later in other macros in other worksheets and in "ThisWorkbook".
How do I do this?

Thanks.





All times are GMT +1. The time now is 07:17 PM.

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