+ Reply to Thread
Results 1 to 3 of 3

Dynamic arrays

  1. #1
    Registered User
    Join Date
    08-14-2012
    Location
    Moscow, Russia
    MS-Off Ver
    Excel 2010
    Posts
    3

    Dynamic arrays

    Hello,

    Does VBA allow to use dynamic arrays? I've got a problem with redimensioning.

    'Declare an array in general declaraions
    Dim ShityArray (1,1) as String

    'Then i try to redimension it in the cmdButton_click sub
    Dim a As Integer
    Dim b As Integer
    a = 10
    b = 10
    ReDim Preserve ShityArray (a,b) As String

    Result: VBA says "Compile error: Array already dimensioned"

    Besides, i need to calculate "a" and "b" first, but VBA swears that dimesion should be declared by a constant.
    Is it posible to declare dimensions with a variable? Or capture the value for constant from a textbox?
    Last edited by Rockafella; 08-22-2012 at 08:12 AM.

  2. #2
    Forum Expert
    Join Date
    09-27-2011
    Location
    Poland
    MS-Off Ver
    Excel 2007
    Posts
    1,312

    Re: Dynamic arrays

    Hi try this
    Please Login or Register  to view this content.
    Regards

    tom1977

    If You are satisfied with my solution click the small star icon on the left to say thanks.

  3. #3
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Dynamic arrays

    BTW, there is no point in preserving an empty array.
    Remember what the dormouse said
    Feed your head

  4. #4
    Registered User
    Join Date
    08-14-2012
    Location
    Moscow, Russia
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Dynamic arrays

    Yep! That works pretty well.
    Many thanks!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1