Macro Error Message - Subscript out of range
Macro Error Message - Subscript out of range
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 3 of 3

Thread: Macro Error Message - Subscript out of range

  1. #1
    Board Regular
    Join Date
    Feb 2002
    Location
    Houston, TX
    Posts
    357
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    I get the followinf error message

    "Subscript out of range"

    What does that mean?

  2. #2
    MrExcel MVP Al Chara's Avatar
    Join Date
    Feb 2002
    Location
    Newark, Delaware
    Posts
    1,701
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    From the help file:

    Elements of arrays and members of collections can only be accessed within their defined ranges. This error has the following causes and solutions:

    You referenced a nonexistent array element.
    The subscript may be larger or smaller than the range of possible subscripts, or the array may not have dimensions assigned at this point in the application. Check the declaration of the array to verify its upper and lower bounds. Use the UBound and LBound functions to condition array accesses if you're working with arrays that are redimensioned. If the index is specified as a variable, check the spelling of the variable name.

    You declared an array but didn't specify the number of elements. For example, the following code causes this error:
    Dim MyArray() As Integer
    MyArray(8) = 234 ' Causes Error 9.

    Visual Basic doesn't implicitly dimension unspecified array ranges as 0 10. Instead, you must use Dim or ReDim to specify explicitly the number of elements in an array.

    You referenced a nonexistent collection member.
    Try using the For Each...Next construct instead of specifying index elements.

    You used a shorthand form of subscript that implicitly specified an invalid element.
    For example, when you use the ! operator with a collection, the ! implicitly specifies a key. For example, object!keyname.value is equivalent to object.item(keyname).value. In this case, an error is generated if keyname represents an invalid key in the collection. To fix the error, use a valid key name or index for the collection.
    Best regards,
    Allan Chara
    http://www.mrspreadsheets.com

  3. #3
    Board Regular
    Join Date
    Feb 2002
    Location
    Houston, TX
    Posts
    357
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Found something else, about "Visual Basic for Applications Procedure to Open or Activate a Workbook"

    That happens to be part of the code that I was having problems with!

    http://support.microsoft.com/search/...;en-us;Q213395

    [ This Message was edited by: Cosmos75 on 2002-04-12 14:52 ]

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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

 

DMCA.com