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

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!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default Global Variables

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!


  #3   Report Post  
Posted to microsoft.public.excel.programming
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!


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
Global Variables Karen53 Excel Programming 12 April 16th 08 07:14 PM
Global variables Ed Excel Programming 6 November 19th 06 10:55 PM
Global Variables [email protected] Excel Programming 0 July 7th 06 10:53 AM
global variables Mike Archer Excel Programming 4 May 3rd 06 07:33 PM
Global Variables Ernst Guckel[_4_] Excel Programming 2 May 7th 05 11:10 PM


All times are GMT +1. The time now is 10:42 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"