![]() |
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! |
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! |
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! |
All times are GMT +1. The time now is 02:50 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com