#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default 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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default 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
.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Assigning a Variable to an Expression that Includes a Variable andVBA Property bluebird[_3_] Excel Programming 3 April 27th 09 07:38 AM
Nothing Keyword Destories Objects rather than just resetting the variable to an empty variable Ronald R. Dodge, Jr.[_2_] Excel Programming 15 December 15th 08 09:19 PM
why is it saying sheetcnt is "variable not defined" how to do a global variable to share over multiple functions in vba for excel? Daniel Excel Worksheet Functions 1 July 9th 05 03:05 AM
Run-time error '91': "Object variable or With block variable not set Mike[_92_] Excel Programming 2 December 30th 04 10:59 AM
Cells.Find error Object variable or With block variable not set Peter[_21_] Excel Programming 2 May 8th 04 02:15 PM


All times are GMT +1. The time now is 01:20 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"