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: 1
Default Public variable defintion (newbie)


I have two questions.

Is a public variable visible to all sub procedures in all modules bu
just under one workbook? In this case a public variable has bee
declared in a module under Personal.xls, but I also have anothe
workbook containing macros but am confused as to whether a public va
is visible to all workbooks - I only want it visible unde
Personal.xls.

Lastly, I've created a userform whereby the user has 3 options (usin
option buttons) and an OK and CANCEL button. I noticed th
"CommandButton1_Click()" userform is always preceded m
"private"...namely -

Private Sub CommandButton1_Click()

If OptButton_All Then
arSelect = Array("N3", "N2", "O-P", "SO4")
Else
If OptButton_SulphateOnly Then
arSelect = Array("SO4")
Else
If OptButton_ExcludeSulphate Then
arSelect = Array("N3", "N2", "O-P")
Else
MsgBox "You must select an option!"
Hide
Show

End If
End If
End If


Unload Me


End Sub


The array "arSelect" is declared as "Public arSelect As Variant" at th
very start of module 1. The module then opens the userform. Th
userform captures the selection and assigns a series of value(s) t
arSelect. I want arSelect to be available to module1.

I noticed that if I changed the "Private Sub CommandButton1_Click()" t
"*Public* Sub CommandButton1_Click()" then arSelect is then available t
module 1, but refuses to work if it is Private.

I guess I've answered my own question, but why does a userfor
automatically delcare procedures as private?

Thanks

--
gregg
-----------------------------------------------------------------------
gregga's Profile: http://www.excelforum.com/member.php...nfo&userid=987
View this thread: http://www.excelforum.com/showthread.php?threadid=26710

 
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
Public variable Jack New Users to Excel 4 March 18th 06 09:35 PM
Public variable usage! Tom Ogilvy Excel Programming 0 April 14th 04 03:34 AM
Public Variable Jason Excel Programming 4 April 12th 04 07:06 PM
Scope of a public variable Jos Vens Excel Programming 0 November 24th 03 10:08 AM
public variable marwan hefnawy Excel Programming 1 September 5th 03 08:54 AM


All times are GMT +1. The time now is 11:59 PM.

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"