View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
MM User MM User is offline
external usenet poster
 
Posts: 27
Default Global Variables

Thanks Per - that's great!

"Per Jessen" wrote in message
...
Hi

Yes, it's possible...

The secret is to declare the variables outside your macro (at the top of
the module).

Try this:

Private Sub Workbook_Open()
Call myvalues
Call output
End Sub

Dim ProjectTitle As String
Public Sub myvalues()
ProjectTitle = "my Project"
End Sub

Sub output()
msg = MsgBox("ProjectTitle = " & ProjectTitle)
End Sub

For more information about declaring variables, look at this:

http://www.cpearson.com/excel/variables.htm

Best regards,
Per

"MM User" skrev i meddelelsen
...
Hi,

Is it possible to add a sub that can be used to set all variables:

Private Sub Workbook_Open()
Run setvalues
End Sub

Public Sub myvalues()
ProjectTitle = "my Project"
End Sub

Thanks!