Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default Declare Variable

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
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
Declare Variable zapatista66[_10_] Excel Programming 0 October 6th 04 09:02 PM
Declare Variable zapatista66[_9_] Excel Programming 1 October 6th 04 08:47 PM
Declare an Array() ???? Andoni[_23_] Excel Programming 1 August 31st 04 07:12 PM
How to declare variable as Excel constant? John Wirt[_6_] Excel Programming 2 August 22nd 04 05:41 PM
How do i declare a formula with prenamed variable Jeff Excel Programming 1 June 25th 04 06:09 PM


All times are GMT +1. The time now is 10:02 PM.

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

About Us

"It's about Microsoft Excel"