Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 54
Default Global Array Constant

Using Excel 2003.

I have an array of button captions that I am using to loop through some of
the buttons on a pop-up control on a custom toolbar. The array is required in
several different procedures, so I would like a solution to avoid having to
declare it in each procedure. Normally, I would just loop through all of the
controls contained in the pop-up, but there are three buttons that need to be
handled different from the rest, so that solution doesn't work in this case.
My current code that I am using in each procedure is:

Dim ButtonNames() As Variant

ButtonNames = Array("Next Level", "All Levels", "Bottom Level", "Use
Siblings", _
"Same Level", "Same Generation", "Calc Level", "Include Selected", _
"Within Selected Groups", "Remove Unselected Groups")

My first thought was to try and declare it as a global constant as follows,
but that didn't work out so well:

Public Const ButtonNames as Variant = Array("Next Level", "All Levels", _
"Bottom Level", "Use Siblings", "Same Level", "Same Generation", _
"Calc Level", "Include Selected", "Within Selected Groups", _
"Remove Unselected Groups")

Any helpfully solutions that you could provide would be greatly appreciated.

-Cory
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Global Array Constant

Public ButtonNames as variant

Sub Auto_Open()

ButtonNames = Array("Next Level", "All Levels", "Bottom Level", _
"Use Siblings", _
"Same Level", "Same Generation", "Calc Level", "Include Selected", _
"Within Selected Groups", "Remove Unselected Groups")
End sub

As soon as the workbook is opened, the assignment will be done.



Cory wrote:

Using Excel 2003.

I have an array of button captions that I am using to loop through some of
the buttons on a pop-up control on a custom toolbar. The array is required in
several different procedures, so I would like a solution to avoid having to
declare it in each procedure. Normally, I would just loop through all of the
controls contained in the pop-up, but there are three buttons that need to be
handled different from the rest, so that solution doesn't work in this case.
My current code that I am using in each procedure is:

Dim ButtonNames() As Variant

ButtonNames = Array("Next Level", "All Levels", "Bottom Level", "Use
Siblings", _
"Same Level", "Same Generation", "Calc Level", "Include Selected", _
"Within Selected Groups", "Remove Unselected Groups")

My first thought was to try and declare it as a global constant as follows,
but that didn't work out so well:

Public Const ButtonNames as Variant = Array("Next Level", "All Levels", _
"Bottom Level", "Use Siblings", "Same Level", "Same Generation", _
"Calc Level", "Include Selected", "Within Selected Groups", _
"Remove Unselected Groups")

Any helpfully solutions that you could provide would be greatly appreciated.

-Cory


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 54
Default Global Array Constant

Thanks for your help, Dave. Since that works, does that mean that global
variables are persistent and retain their values between procedure calls?

-Cory

"Dave Peterson" wrote:

Public ButtonNames as variant

Sub Auto_Open()

ButtonNames = Array("Next Level", "All Levels", "Bottom Level", _
"Use Siblings", _
"Same Level", "Same Generation", "Calc Level", "Include Selected", _
"Within Selected Groups", "Remove Unselected Groups")
End sub

As soon as the workbook is opened, the assignment will be done.



Cory wrote:

Using Excel 2003.

I have an array of button captions that I am using to loop through some of
the buttons on a pop-up control on a custom toolbar. The array is required in
several different procedures, so I would like a solution to avoid having to
declare it in each procedure. Normally, I would just loop through all of the
controls contained in the pop-up, but there are three buttons that need to be
handled different from the rest, so that solution doesn't work in this case.
My current code that I am using in each procedure is:

Dim ButtonNames() As Variant

ButtonNames = Array("Next Level", "All Levels", "Bottom Level", "Use
Siblings", _
"Same Level", "Same Generation", "Calc Level", "Include Selected", _
"Within Selected Groups", "Remove Unselected Groups")

My first thought was to try and declare it as a global constant as follows,
but that didn't work out so well:

Public Const ButtonNames as Variant = Array("Next Level", "All Levels", _
"Bottom Level", "Use Siblings", "Same Level", "Same Generation", _
"Calc Level", "Include Selected", "Within Selected Groups", _
"Remove Unselected Groups")

Any helpfully solutions that you could provide would be greatly appreciated.

-Cory


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Global Array Constant

They're persistent until you do something bad--hit the End key (while
debugging)--or have a line like:

End
(not "end sub", "end function", "end if"--just plain old End.)

You may want to create a dedicated routine that initializes these global
variables.

Then add one mo

Public VariablesAreInitialized as boolean

Then later you can use:

if variablesareinitialized then
'keep going
else
call dedicatedroutinetoinitializevariables
end if

sub dedicatedroutinetoinitializevariables()
buttonnames = array(...)
...all you need
variablesareinitialized = true
end sub

just in case something unexpected goes wrong.



Cory wrote:

Thanks for your help, Dave. Since that works, does that mean that global
variables are persistent and retain their values between procedure calls?

-Cory

"Dave Peterson" wrote:

Public ButtonNames as variant

Sub Auto_Open()

ButtonNames = Array("Next Level", "All Levels", "Bottom Level", _
"Use Siblings", _
"Same Level", "Same Generation", "Calc Level", "Include Selected", _
"Within Selected Groups", "Remove Unselected Groups")
End sub

As soon as the workbook is opened, the assignment will be done.



Cory wrote:

Using Excel 2003.

I have an array of button captions that I am using to loop through some of
the buttons on a pop-up control on a custom toolbar. The array is required in
several different procedures, so I would like a solution to avoid having to
declare it in each procedure. Normally, I would just loop through all of the
controls contained in the pop-up, but there are three buttons that need to be
handled different from the rest, so that solution doesn't work in this case.
My current code that I am using in each procedure is:

Dim ButtonNames() As Variant

ButtonNames = Array("Next Level", "All Levels", "Bottom Level", "Use
Siblings", _
"Same Level", "Same Generation", "Calc Level", "Include Selected", _
"Within Selected Groups", "Remove Unselected Groups")

My first thought was to try and declare it as a global constant as follows,
but that didn't work out so well:

Public Const ButtonNames as Variant = Array("Next Level", "All Levels", _
"Bottom Level", "Use Siblings", "Same Level", "Same Generation", _
"Calc Level", "Include Selected", "Within Selected Groups", _
"Remove Unselected Groups")

Any helpfully solutions that you could provide would be greatly appreciated.

-Cory


--

Dave Peterson


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Global Array Constant

Yes, they do.

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Cory" wrote in message
...
Thanks for your help, Dave. Since that works, does that mean that global
variables are persistent and retain their values between procedure calls?

-Cory

"Dave Peterson" wrote:

Public ButtonNames as variant

Sub Auto_Open()

ButtonNames = Array("Next Level", "All Levels", "Bottom Level", _
"Use Siblings", _
"Same Level", "Same Generation", "Calc Level", "Include
Selected", _
"Within Selected Groups", "Remove Unselected Groups")
End sub

As soon as the workbook is opened, the assignment will be done.



Cory wrote:

Using Excel 2003.

I have an array of button captions that I am using to loop through some
of
the buttons on a pop-up control on a custom toolbar. The array is
required in
several different procedures, so I would like a solution to avoid
having to
declare it in each procedure. Normally, I would just loop through all
of the
controls contained in the pop-up, but there are three buttons that need
to be
handled different from the rest, so that solution doesn't work in this
case.
My current code that I am using in each procedure is:

Dim ButtonNames() As Variant

ButtonNames = Array("Next Level", "All Levels", "Bottom Level",
"Use
Siblings", _
"Same Level", "Same Generation", "Calc Level", "Include
Selected", _
"Within Selected Groups", "Remove Unselected Groups")

My first thought was to try and declare it as a global constant as
follows,
but that didn't work out so well:

Public Const ButtonNames as Variant = Array("Next Level", "All
Levels", _
"Bottom Level", "Use Siblings", "Same Level", "Same
Generation", _
"Calc Level", "Include Selected", "Within Selected Groups", _
"Remove Unselected Groups")

Any helpfully solutions that you could provide would be greatly
appreciated.

-Cory


--

Dave Peterson





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 54
Default Global Array Constant

Good idea. Thanks again for all your help.

"Dave Peterson" wrote:

They're persistent until you do something bad--hit the End key (while
debugging)--or have a line like:

End
(not "end sub", "end function", "end if"--just plain old End.)

You may want to create a dedicated routine that initializes these global
variables.

Then add one mo

Public VariablesAreInitialized as boolean

Then later you can use:

if variablesareinitialized then
'keep going
else
call dedicatedroutinetoinitializevariables
end if

sub dedicatedroutinetoinitializevariables()
buttonnames = array(...)
...all you need
variablesareinitialized = true
end sub

just in case something unexpected goes wrong.



Cory wrote:

Thanks for your help, Dave. Since that works, does that mean that global
variables are persistent and retain their values between procedure calls?

-Cory

"Dave Peterson" wrote:

Public ButtonNames as variant

Sub Auto_Open()

ButtonNames = Array("Next Level", "All Levels", "Bottom Level", _
"Use Siblings", _
"Same Level", "Same Generation", "Calc Level", "Include Selected", _
"Within Selected Groups", "Remove Unselected Groups")
End sub

As soon as the workbook is opened, the assignment will be done.



Cory wrote:

Using Excel 2003.

I have an array of button captions that I am using to loop through some of
the buttons on a pop-up control on a custom toolbar. The array is required in
several different procedures, so I would like a solution to avoid having to
declare it in each procedure. Normally, I would just loop through all of the
controls contained in the pop-up, but there are three buttons that need to be
handled different from the rest, so that solution doesn't work in this case.
My current code that I am using in each procedure is:

Dim ButtonNames() As Variant

ButtonNames = Array("Next Level", "All Levels", "Bottom Level", "Use
Siblings", _
"Same Level", "Same Generation", "Calc Level", "Include Selected", _
"Within Selected Groups", "Remove Unselected Groups")

My first thought was to try and declare it as a global constant as follows,
but that didn't work out so well:

Public Const ButtonNames as Variant = Array("Next Level", "All Levels", _
"Bottom Level", "Use Siblings", "Same Level", "Same Generation", _
"Calc Level", "Include Selected", "Within Selected Groups", _
"Remove Unselected Groups")

Any helpfully solutions that you could provide would be greatly appreciated.

-Cory

--

Dave Peterson


--

Dave Peterson

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
public or global array shishi Excel Programming 2 February 6th 06 09:29 PM
Global array declare Souris Excel Programming 3 August 20th 05 11:38 AM
A constant array? Thief_ Excel Programming 3 April 21st 05 10:48 AM
constant array Sam Excel Programming 4 May 8th 04 02:56 AM
Referring to a local or global variable or constant dynamically? PC[_2_] Excel Programming 1 September 15th 03 02:31 PM


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