Declaring arrays

  • Thread starter Thread starter DKS
  • Start date Start date
What i need to do:

Declare an array, but size unknown. Thus, programmatically I need to expand
the size.
 
You need to use a Dynamic Array; that is, an array whose bounds are not
specified in the Dim statement but rather set at run-time with the Redim
function. For example,

Dim Arr() As String
Dim N As Long

N = SomeValue
Redim Arr(1 to N)

If you use Redim on an existing array, the contents of the array are
destroyed unless you use the Preserve modifer:

Redim Preserve Arr(1 To N)



--
Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2008
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)
 

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