+ Reply to Thread
Results 1 to 3 of 3

Redim array - out of range

  1. #1
    Registered User
    Join Date
    09-10-2014
    Location
    Matrix
    MS-Off Ver
    2010
    Posts
    70

    Redim array - out of range

    Dear all,

    I know that problem is obvious but now for me I have darkness in my mind. I try to load data from excel cells to variant array. Data is in columns A and B. My code:
    Please Login or Register  to view this content.
    And unfortunately I get error 'Subscription out of range'
    Last edited by michson; 04-30-2015 at 03:35 AM.
    (*) Reputation points appreciated.
    excelbs.tk

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Redim array - out of range

    You can only alter the outer dimension of the array when using ReDim Preserve

    Direct from help file on ReDim
    If you use the Preserve keyword, you can resize only the last array dimension and you can't change the number of dimensions at all. For example, if your array has only one dimension, you can resize that dimension because it is the last and only dimension. However, if your array has two or more dimensions, you can change the size of only the last dimension and still preserve the contents of the array. The following example shows how you can increase the size of the last dimension of a dynamic array without erasing any existing data contained in the array.
    If you locate the last row you can use this instead
    Please Login or Register  to view this content.
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    09-10-2014
    Location
    Matrix
    MS-Off Ver
    2010
    Posts
    70

    Re: Redim array - out of range

    Andy Pope, thanks for explanation. I know this is the fastest way to load data to array and I use it always. But this case was for just practise.
    Reputation point for you ;-)

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Subscript out of range - ReDim Preserve an array
    By dejavision in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-13-2014, 04:29 PM
  2. [SOLVED] Redim Preserve array: subscript out of range
    By supern0va in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-02-2012, 12:58 PM
  3. redim array error....subscript out of range
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-07-2011, 11:07 AM
  4. Assign sheet value to array... and redim the array size
    By Orange.CL in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-27-2010, 07:18 AM
  5. dynamic array redim preserve: run-time error 9, Subscript out of range.
    By Broesel in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-20-2009, 08:39 AM

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