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


Just to be sure I'm right:

First I write:

Option Explicit
Global gwksZap As Worksheet
Sub SetRefs()
Set gwksZap = ThisWorkbook.Worksheets("Zapatista66")
End Sub

in a module or in each module I need those variables ?

After:

Private Sub Workbook_Open()
Call SetRefs
gwksZap.Activate
End Sub

Finally:

All my declaration in the worksheet (Microsoft Excel Objet) like that:

Set wbBook1 = Workbooks("Logiciel_Production_Soumission.xls")
Set wbBook2 = Workbooks("Projets.xls")
Set wbBook3 = Workbooks("Liste_Prix.xls")
Set wbBook4 = Workbooks("Clients.xls")
Set wbBook5 = Workbooks("Template_Soumission.xls")

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default Declare Variable

In a "pure" code module (not worksheet module):
Option Explicit
Dim wbBook1 as Workbook
etc ...
Public Sub SetRefs()
Set wbBook1 = Workbooks
("Logiciel_Production_Soumission.xls")
etc ...
End Sub

Then, in any other worksheet module or code module, you
just have to refer to wbBook1. You don't have to make
another Set statement again. For example:
Private Sub Workbook_Open()
Call SetRefs()
wbBook1.Activate
End Sub

Geof.
-----Original Message-----

Just to be sure I'm right:

First I write:

Option Explicit
Global gwksZap As Worksheet
Sub SetRefs()
Set gwksZap = ThisWorkbook.Worksheets("Zapatista66")
End Sub

in a module or in each module I need those variables ?

After:

Private Sub Workbook_Open()
Call SetRefs
gwksZap.Activate
End Sub

Finally:

All my declaration in the worksheet (Microsoft Excel

Objet) like that:

Set wbBook1 = Workbooks

("Logiciel_Production_Soumission.xls")
Set wbBook2 = Workbooks("Projets.xls")
Set wbBook3 = Workbooks("Liste_Prix.xls")
Set wbBook4 = Workbooks("Clients.xls")
Set wbBook5 = Workbooks("Template_Soumission.xls")

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

.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default Declare Variable: 1 more thing

I forgot to mention that if you call SetRefs in the
workbook open event, you shouldn't have to call SetRefs
again. But if you ever have a runtime error that's not
trapped, references to these objects are destroyed, and
somehow you have to re-run SetRefs.
Geof.
-----Original Message-----

Just to be sure I'm right:

First I write:

Option Explicit
Global gwksZap As Worksheet
Sub SetRefs()
Set gwksZap = ThisWorkbook.Worksheets("Zapatista66")
End Sub

in a module or in each module I need those variables ?

After:

Private Sub Workbook_Open()
Call SetRefs
gwksZap.Activate
End Sub

Finally:

All my declaration in the worksheet (Microsoft Excel

Objet) like that:

Set wbBook1 = Workbooks

("Logiciel_Production_Soumission.xls")
Set wbBook2 = Workbooks("Projets.xls")
Set wbBook3 = Workbooks("Liste_Prix.xls")
Set wbBook4 = Workbooks("Clients.xls")
Set wbBook5 = Workbooks("Template_Soumission.xls")

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

.

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[_11_] Excel Programming 1 October 7th 04 03:23 PM
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
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 05:36 AM.

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"