PC Review


Reply
Thread Tools Rate Thread

Declaring arrays

 
 
DKS
Guest
Posts: n/a
 
      13th Feb 2008
Can somebody remind me the syntax to declare arrays in Excel modules?
 
Reply With Quote
 
 
 
 
DKS
Guest
Posts: n/a
 
      13th Feb 2008
What i need to do:

Declare an array, but size unknown. Thus, programmatically I need to expand
the size.

"DKS" wrote:

> Can somebody remind me the syntax to declare arrays in Excel modules?

 
Reply With Quote
 
Suhas
Guest
Posts: n/a
 
      13th Feb 2008
Dim MyIntegerArray() As Integer

Use ReDim to define it at runtime
"DKS" wrote:

> What i need to do:
>
> Declare an array, but size unknown. Thus, programmatically I need to expand
> the size.
>
> "DKS" wrote:
>
> > Can somebody remind me the syntax to declare arrays in Excel modules?

 
Reply With Quote
 
DKS
Guest
Posts: n/a
 
      13th Feb 2008
Thanks Suhas. That is exactly what I was trying to remember.

"Suhas" wrote:

> Dim MyIntegerArray() As Integer
>
> Use ReDim to define it at runtime
> "DKS" wrote:
>
> > What i need to do:
> >
> > Declare an array, but size unknown. Thus, programmatically I need to expand
> > the size.
> >
> > "DKS" wrote:
> >
> > > Can somebody remind me the syntax to declare arrays in Excel modules?

 
Reply With Quote
 
Chip Pearson
Guest
Posts: n/a
 
      13th Feb 2008
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)

"DKS" <(E-Mail Removed)> wrote in message
news:54164EBE-5AE2-4136-9665-(E-Mail Removed)...
> What i need to do:
>
> Declare an array, but size unknown. Thus, programmatically I need to
> expand
> the size.
>
> "DKS" wrote:
>
>> Can somebody remind me the syntax to declare arrays in Excel modules?


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Declaring Arrays - Syntax DesCF Microsoft VB .NET 2 21st Jul 2007 03:54 PM
Declaring 2 dimensional arrays Dan Microsoft Excel Programming 4 17th Nov 2005 08:36 PM
Declaring 2 dimensional arrays Dan Microsoft Access Macros 1 15th Nov 2005 10:06 PM
Declaring structure arrays John Dann Microsoft VB .NET 1 15th Jun 2005 11:14 AM
Declaring arrays Alan Beban Microsoft Excel Programming 22 12th May 2004 08:10 AM


Features
 

Advertising
 

Newsgroups
 


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