Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Public variable not accessable

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,365
Default Public variable not accessable

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Public variable not accessable

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default Public variable not accessable

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
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
Disappearing Public Variable donbowyer Excel Programming 8 September 20th 06 07:42 PM
Public variable Jack New Users to Excel 4 March 18th 06 09:35 PM
How to declare variable as public. Mark Excel Programming 3 April 7th 05 06:27 PM
Public Variable Jason Excel Programming 4 April 12th 04 07:06 PM
public variable marwan hefnawy Excel Programming 1 September 5th 03 08:54 AM


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