ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Declare Variable (https://www.excelbanter.com/excel-programming/312712-declare-variable.html)

zapatista66[_9_]

Declare Variable
 

Hola Todos ! I need some help. I want to declare some variables for al
my modules.

Ex:

Public wbBook1 as workbook, wbBook2, etc

Set wbBook1 = workbooks("roger.xls")

I don't want to write these lines in each modules. Want I start m
principal workbook I open all workbooks needed in my programmation
After, I look in some workbook and I write in the other.

thanks for helping m

--
zapatista6

-----------------------------------------------------------------------
zapatista66's Profile: http://www.excelforum.com/member.php...fo&userid=1195
View this thread: http://www.excelforum.com/showthread.php?threadid=26698


Geof Wyght[_2_]

Declare Variable
 
Zapatista66,
You're almost there. In your Workbook_Open procedure call
another public procedure that I call SetRefs. SetRefs has
all of your Set statements and you make the all of the
objects global in scope. Then your other procs will see
the objects.
Also, while testing a procedure, throw SetRefs into the
top of the procedure so when you get a runtime error you
don't have to go look for Workbook_Open or SetRefs again.
Just fix your code and F5.
Geof.
-----Original Message-----

Hola Todos ! I need some help. I want to declare some

variables for all
my modules.

Ex:

Public wbBook1 as workbook, wbBook2, etc

Set wbBook1 = workbooks("roger.xls")

I don't want to write these lines in each modules. Want I

start my
principal workbook I open all workbooks needed in my

programmation.
After, I look in some workbook and I write in the other.

thanks for helping me


--
zapatista66


----------------------------------------------------------

--------------
zapatista66's Profile:

http://www.excelforum.com/member.php?
action=getinfo&userid=11956
View this thread:

http://www.excelforum.com/showthread...hreadid=266983

.



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

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