LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 577
Default global variable not seen

I have a simple workbook with 1 sheet and a command button to run some code.
Under "Microsoft Excel Objects", Sheet1 I have this code:

Public Y As String
Public Sub CommandButton1_Click()
X = "passed parameter"
Y = "global variable"
testmodule (X)
End Sub

Under "Modules", Module1 I have this code:

Public Sub testmodule(X As String)
MsgBox ("X is " + X)
MsgBox ("Y is " + Y)
End Sub

When I press the command button I see two message boxes. The first says :

"X is passed parameter"

and the second says

"Y is "

Question is how can I get the Y variable seen in Module1 without passing it
as a parameter? In other words have the message box say "Y is global
variable".

 
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 variable dhstein Excel Discussion (Misc queries) 2 October 30th 09 01:03 PM
Global Variable dhstein Excel Discussion (Misc queries) 4 July 26th 09 05:10 PM
Global Variable Patrick Simonds Excel Programming 8 October 6th 05 12:39 AM
why is it saying sheetcnt is "variable not defined" how to do a global variable to share over multiple functions in vba for excel? Daniel Excel Worksheet Functions 1 July 9th 05 03:05 AM
Global variable Don[_11_] Excel Programming 1 October 28th 03 04:15 AM


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