Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Finally, I have another question: I wrote your SetRefs procedure in ThisWorkbook, but my VBA have a lo of UserForm, Modules. So I have to declare my variable in each userfor and modules. I understand that your answer is good for each procedure in a module but I want to declare once to all my VBA (Workbook). Is it clear enough -- zapatista6 ----------------------------------------------------------------------- zapatista66's Profile: http://www.excelforum.com/member.php...fo&userid=1195 View this thread: http://www.excelforum.com/showthread.php?threadid=26698 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Zapatista66,
I could have been more careful in my first reply. This should help. Declare your global variables at the top of the module, not inside the SetRefs proc. Like this: Option Explicit Global gwksZap As Worksheet Sub SetRefs() Set gwksZap = ThisWorkbook.Worksheets("Zapatista66") End Sub Then in some other procedure say, Workbook_Open you do: Private Sub Workbook_Open() Call SetRefs gwksZap.Activate End Sub I tested this. By the way, I use the Hungarian convention. So "g" in "gwksZap" stands for "global", That way when you see the object name in some proc, you know where to look to see where it is declared. Good luck! Geof. -----Original Message----- Finally, I have another question: I wrote your SetRefs procedure in ThisWorkbook, but my VBA have a lot of UserForm, Modules. So I have to declare my variable in each userform and modules. I understand that your answer is good for each procedure in a module, but I want to declare once to all my VBA (Workbook). Is it clear enough ? -- zapatista66 ---------------------------------------------------------- -------------- zapatista66's Profile: http://www.excelforum.com/member.php? action=getinfo&userid=11956 View this thread: http://www.excelforum.com/showthread...hreadid=266983 . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Declare Variable | Excel Programming | |||
Declare Variable | Excel Programming | |||
Declare an Array() ???? | Excel Programming | |||
How to declare variable as Excel constant? | Excel Programming | |||
How do i declare a formula with prenamed variable | Excel Programming |