ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Global variable declaration! (https://www.excelbanter.com/excel-programming/294951-global-variable-declaration.html)

aiyer[_12_]

Global variable declaration!
 
Hello all!

A quick question.
I declared several global variables and was trying to use them i
different macros.For soem reason they are'nt recognized by the macros
The following were the ones I declared as global variables.

Dim store As Integer
Dim loct As Integer
Dim res As Integer
Dim ng As Integer

Should I declare the above in a seperate macro or something and mak
that macro available to the rest of the macros? Is that possible? Ho
do I do this? I might need to use the variable 'store' in a macro sa
'calculate'.

I would appreciate your help guys.
Thanks.

Arun...
Vtec corp

--
Message posted from http://www.ExcelForum.com


kkknie[_32_]

Global variable declaration!
 
They should go outside of any Subroutine in a Module (not a workbook o
worksheet). Also, they should be delcared as public:

Public store As Integer
Public loct As Integer
Public res As Integer
Public ng As Integer



--
Message posted from http://www.ExcelForum.com


Leo Heuser[_3_]

Global variable declaration!
 
Hello Arun

A quick answer :-)

Public store As Integer
Public loct As Integer
Public res As Integer
Public ng As Integer

At the top of a *general* module will do the trick.

--
Best Regards
Leo Heuser

Followup to newsgroup only please.

"aiyer " skrev i en meddelelse
...
Hello all!

A quick question.
I declared several global variables and was trying to use them in
different macros.For soem reason they are'nt recognized by the macros.
The following were the ones I declared as global variables.

Dim store As Integer
Dim loct As Integer
Dim res As Integer
Dim ng As Integer

Should I declare the above in a seperate macro or something and make
that macro available to the rest of the macros? Is that possible? How
do I do this? I might need to use the variable 'store' in a macro say
'calculate'.

I would appreciate your help guys.
Thanks.

Arun...
Vtec corp.


---
Message posted from http://www.ExcelForum.com/




aiyer[_13_]

Global variable declaration!
 
Thanks a bunch kkknie...
That helps..

Regds.

Arun

--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 09:30 PM.

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