Array Declaration

  • Thread starter Thread starter mikey10
  • Start date Start date
M

mikey10

Hi

I'm trying to use an fixed array. Several macros will need to use thi
array and the contents of the array will be subject to continuou
changes.
Where and how do I declare the existence and size of this array?
Regards,
Mike
:
 
If you write

Dim MyArray(1 to 30) As Variant

at the top of the module, outside of any procedures, it will be available to
all procedures in the module. Note that what I wrote is a fixed-sized or
static array. You can't change the size with a Redim statement. If you want to
do that, write it as

Dim MyArray() AS Variant

One of your procedures must, of course, use Redim to set the size.
 
Several macros will need to use this array

Then you should declare it at the top of a standard module:

Dim MyArray(1 to 100, 1 to 2) as String

If some of the routines that will use the array are in other modules then
you have to declare the variable as Public:

Public MyArray(1 to 100, 1 to 2) as String

--
Jim Rech
Excel MVP
|
| Hi
|
| I'm trying to use an fixed array. Several macros will need to use this
| array and the contents of the array will be subject to continuous
| changes.
| Where and how do I declare the existence and size of this array?
| Regards,
| Mike
| :)
|
|
| --
| mikey10
| ------------------------------------------------------------------------
| mikey10's Profile:
http://www.excelforum.com/member.php?action=getinfo&userid=15378
| View this thread: http://www.excelforum.com/showthread.php?threadid=270204
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top