Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Across Excel Workbooks in VB

Status
Not open for further replies.

q4s72534

MIS
Aug 19, 2003
59
US
Do you kwno what is the way to define the variable project wide....
 
Basically delare the variable as Public outside any procedures, within a module. For example in module1

Code:
Option Explicit
Public myVar As String

Then in module2 and sheet1 module you may have the following code respectively which will pick up the declaration of the variable from module1.

Code:
Option Explicit

Sub a()
myVar = Format(Now, "hh:mm:ss")
MsgBox myVar
End Sub

and

Code:
Option Explicit

Private Sub Worksheet_Activate()
myVar = Format(Now, "hh:mm:ss")
MsgBox myVar
End Sub

Hope this helps!
;-)

If a man says something and there are no women there to hear him, is he still wrong? [ponder]
The faqs ma'am, just the faqs. Get the best from these forums : faq222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top