View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Norman Jones Norman Jones is offline
external usenet poster
 
Posts: 5,302
Default Public Declerations

Hi Shawn,

Declare the variables at module level.

You can initialise them and then use them throughout the module, e.g.:


Option Explicit

Dim WSDSD As Worksheet
Dim WSRep As Worksheet
Dim WSCri As Worksheet


Sub Initialise()
Set WSDSD = Worksheets(1) '("Data SD")
Set WSRep = Worksheets(2) '("Report")
Set WSCri = Worksheets(3) '("YourSheet")

End Sub


Sub Tester()
Debug.Print WSDSD.Name, WSRep.Name, WSCri.Name,

End Sub

---
Regards,
Norman



"Shawn" wrote in message
...
I have a VBA Module named MasterFormulas. In it will be several
sub-routines. The first one starts like this:

Option Explicit
Public Sub MRR()

'Begin General Declerations

Dim WSDSD As Worksheet
Set WSDSD = Worksheets("Data SD")
Dim WSRep As Worksheet
Set WSRep = Worksheets("Report")
Dim WSCri As Worksheet


In every sub-routine in the module MasterFormulas, I want Excel to
remember
these declerations. How can I avoid having to re-declare these in every
sub-routine?


--
Thanks
Shawn