ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Help with Array Declarations (https://www.excelbanter.com/excel-programming/319274-help-array-declarations.html)

Mark \(InWales\)[_19_]

Help with Array Declarations
 
Hello All

Just a quickie. I have two Userforms that use exactly the same information
in a combobox (different names) if I wanted to only declare the Array once
where would I put it? Both Userforms have the Array declared on the
Userform_Initialize() event so if one of the Userforms wasn't loaded (highly
likely) where and how should I declare?

Many thanks for any help

Mark (InWales)



Chip Pearson

Help with Array Declarations
 
Mark,

You can declare it as a Public variable in a regular code module.
Then, ReDim it, if necessary, in the form's code module.

'[in Module 1]
Public Arr() As String

'[in Form module]
Public Sub Userform_Initialize()
ReDim Arr(1 to whatever)
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Mark (InWales)" wrote in message
...
Hello All

Just a quickie. I have two Userforms that use exactly the same
information in a combobox (different names) if I wanted to only
declare the Array once where would I put it? Both Userforms
have the Array declared on the Userform_Initialize() event so
if one of the Userforms wasn't loaded (highly likely) where and
how should I declare?

Many thanks for any help

Mark (InWales)




Tom Ogilvy

Help with Array Declarations
 
You should declare it as a global variable in a general module. Then
initialize it there as well.

Then either/both userforms can see it.

--
Regards,
Tom Ogilvy

"Mark (InWales)" wrote in message
...
Hello All

Just a quickie. I have two Userforms that use exactly the same

information
in a combobox (different names) if I wanted to only declare the Array once
where would I put it? Both Userforms have the Array declared on the
Userform_Initialize() event so if one of the Userforms wasn't loaded

(highly
likely) where and how should I declare?

Many thanks for any help

Mark (InWales)





Lonnie M.

Help with Array Declarations
 
Hi, insert a module and rename it to 'Main'. At the top declare the
array as a global--"Public myArray As Varriant".
Insert a Procedure within 'Main' and write the code to populate your
array and then call that procedure from your form initialization code.
HTH--Lonnie M.


Mark \(InWales\)[_20_]

Help with Array Declarations
 
Many thanks both.

Mark
"Tom Ogilvy" wrote in message
...
You should declare it as a global variable in a general module. Then
initialize it there as well.

Then either/both userforms can see it.

--
Regards,
Tom Ogilvy

"Mark (InWales)" wrote in message
...
Hello All

Just a quickie. I have two Userforms that use exactly the same

information
in a combobox (different names) if I wanted to only declare the Array
once
where would I put it? Both Userforms have the Array declared on the
Userform_Initialize() event so if one of the Userforms wasn't loaded

(highly
likely) where and how should I declare?

Many thanks for any help

Mark (InWales)








All times are GMT +1. The time now is 01:52 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com