+ Reply to Thread
Results 1 to 4 of 4

Type Mismatch and Subscript out of Range for Static Array

  1. #1
    Registered User
    Join Date
    12-26-2011
    Location
    San Francisco
    MS-Off Ver
    Excel 2010
    Posts
    45

    Type Mismatch and Subscript out of Range for Static Array

    I get 2 different types of errors depending on how I Dim my array. I selected 4 cells when I ran the code below and it throws the error, "subscript out of range" on "MyArray(i, 1) = 1", when i = 1.

    Please Login or Register  to view this content.
    Then when I ran the code by changing the () from the first line, I get Type Mismatch on the MyArray(i,1) line:
    Please Login or Register  to view this content.
    Help! I'm new to arrays and have read through a few tutorials but this is my first time trying one.
    Last edited by BeefNoodleSoup; 03-18-2012 at 06:37 PM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    49,004

    Re: Type Mismatch and Subscript out of Range for Static Array

    The original code worked fine for me with no changes.

    Tried it once with a block of 30 cells and again with just one cell.

    HTML Code: 

    Please Login or Register  to view this content.

    What are you selecting? What's the purpose of the routine?

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    12-26-2011
    Location
    San Francisco
    MS-Off Ver
    Excel 2010
    Posts
    45

    Re: Type Mismatch and Subscript out of Range for Static Array

    This is a bit embarrassing TM, but I had a typo on my side when I named the variables something more descriptive than the example above. My apologies

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    49,004

    Re: Type Mismatch and Subscript out of Range for Static Array

    No problem. We all make mistakes occasionally.

+ 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