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

Hello All,
Im using Excel 2003 and coding in MS VB. Ive declaring variables in
Module 1 Window and created code in Module 1 and Module 7 Windows. I having
problem with variable in Module 7 Windows. The variables are recognized in
M7 while stepping through the code. However, while stepping from M7 to M1,
the variables are not recognized in M1 Window.

How is this problem corrected?

Thanks in advance!
Paul

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Variables not recognized


If you want the variables to be recognized in two different procedures
at module level, the variables must be declared as public variables, out
side any procedu
This can be done in any module. For examaple the module (1 or 7) should
look like below:

Public myNumber As Integer, myString As String
Public '...more public declarations

Sub MyCode()

'code

End Sub.

So define the vairables as Public (not Dim) and define them outside any
Sub procedure.

Sharad

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default Variables not recognized

try the following:
Make the FIRST line of M1: Option Explicit 'this will force you to
declare variables, which is highly recommended
Make line 2 of M1: Public MyVariable1 as String (or as Range etc)

Use the word "Public" in place of "Private" or "Dim"
The declaring a variable as "Public" will make it available across modules.
Once you assign a value to a public variable, say in a procedure in M1, the
value will remain with your variable and can be used in another procedure in
say M7.
The variable VALUE will stay with that variable until you assign a new value
or until you close the file.

"Paul" wrote:

Hello All,
Im using Excel 2003 and coding in MS VB. Ive declaring variables in
Module 1 Window and created code in Module 1 and Module 7 Windows. I having
problem with variable in Module 7 Windows. The variables are recognized in
M7 while stepping through the code. However, while stepping from M7 to M1,
the variables are not recognized in M1 Window.

How is this problem corrected?

Thanks in advance!
Paul

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
UDF Not recognized Rookie_User Excel Worksheet Functions 3 January 29th 10 10:16 PM
value not recognized as a formula Ron@Buy Excel Worksheet Functions 2 February 27th 09 06:36 PM
One cell isn't recognized? LiveUser Excel Discussion (Misc queries) 2 February 14th 08 09:07 PM
Data isn't being recognized. ConfusedDataMonkey Excel Worksheet Functions 1 January 20th 05 04:41 PM
ActiveCell not recognized Snedker Excel Programming 0 January 7th 04 11:16 PM


All times are GMT +1. The time now is 12:26 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"