ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   variable (https://www.excelbanter.com/excel-programming/441816-variable.html)

sarndt

variable
 
If i have a variable that I want to set and use from TheWorkbook, a number of
difference worksheets, a module, and a class module, which General
Declarative section do I put it in, and do I reference it as a Public
Variable or something else.

Thanks

Steve

Jacob Skaria

variable
 
Check out.
http://www.ozgrid.com/VBA/variable-scope-lifetime.htm

--
Jacob (MVP - Excel)


"sarndt" wrote:

If i have a variable that I want to set and use from TheWorkbook, a number of
difference worksheets, a module, and a class module, which General
Declarative section do I put it in, and do I reference it as a Public
Variable or something else.

Thanks

Steve


Dave Peterson

variable
 
I would insert a new module (Insert|Module type) and use:

Public MyVar as Long 'or double or ...


sarndt wrote:

If i have a variable that I want to set and use from TheWorkbook, a number of
difference worksheets, a module, and a class module, which General
Declarative section do I put it in, and do I reference it as a Public
Variable or something else.

Thanks

Steve


--

Dave Peterson

sarndt

variable
 
Dave...

Why would you put it in a new module instead of the existing module Module1?

"Dave Peterson" wrote:

I would insert a new module (Insert|Module type) and use:

Public MyVar as Long 'or double or ...


sarndt wrote:

If i have a variable that I want to set and use from TheWorkbook, a number of
difference worksheets, a module, and a class module, which General
Declarative section do I put it in, and do I reference it as a Public
Variable or something else.

Thanks

Steve


--

Dave Peterson
.


Dave Peterson

variable
 
It's not necessary. I just wanted to make sure that you used a General module
and that was the best way I knew to describe what I wanted.

But I will (usually, but not always), put all my public variables in a dedicated
module -- maybe some initialization routines, too.

But that's just for organizational purposes.

sarndt wrote:

Dave...

Why would you put it in a new module instead of the existing module Module1?

"Dave Peterson" wrote:

I would insert a new module (Insert|Module type) and use:

Public MyVar as Long 'or double or ...


sarndt wrote:

If i have a variable that I want to set and use from TheWorkbook, a number of
difference worksheets, a module, and a class module, which General
Declarative section do I put it in, and do I reference it as a Public
Variable or something else.

Thanks

Steve


--

Dave Peterson
.


--

Dave Peterson


All times are GMT +1. The time now is 08:28 AM.

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