Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have defined a variable Public As String in the Workbook_Open module, but
it is not transferring to other procedures in different modules in the same project. Any thoughts ? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Don't declare it within the Workbook_Open module.
Best place to put global/public variables and constants is in the Declarations section of a regular code module. It will be accessible to all modules from there, including within your Workbook_Open() event processor. If you actually coded it as Public As String then Excel thinks it is a variable named 'Public' that is used within the Workbook_Open() code segment. Public myVariable As String would be the way it should be entered (outside of a sub or function; i.e. in the declarations section). "Daveh" wrote: I have defined a variable Public As String in the Workbook_Open module, but it is not transferring to other procedures in different modules in the same project. Any thoughts ? |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks, it worked !
"JLatham" wrote: Don't declare it within the Workbook_Open module. Best place to put global/public variables and constants is in the Declarations section of a regular code module. It will be accessible to all modules from there, including within your Workbook_Open() event processor. If you actually coded it as Public As String then Excel thinks it is a variable named 'Public' that is used within the Workbook_Open() code segment. Public myVariable As String would be the way it should be entered (outside of a sub or function; i.e. in the declarations section). "Daveh" wrote: I have defined a variable Public As String in the Workbook_Open module, but it is not transferring to other procedures in different modules in the same project. Any thoughts ? |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
The usual practice is to put public variables in a standard module. Public
variables in workbook or worksheet modules are not visible unless qualified with their full name, for example: Msgbox ThisWorkbook.MyVariable -- Jim "Daveh" wrote in message ... |I have defined a variable Public As String in the Workbook_Open module, but | it is not transferring to other procedures in different modules in the same | project. | | Any thoughts ? | | |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Disappearing Public Variable | Excel Programming | |||
Public variable | New Users to Excel | |||
How to declare variable as public. | Excel Programming | |||
Public Variable | Excel Programming | |||
public variable | Excel Programming |