+ Reply to Thread
Results 1 to 9 of 9

Array Subscript Out of Range

  1. #1
    Forum Contributor
    Join Date
    05-13-2010
    Location
    Dallas, TX
    MS-Off Ver
    2019
    Posts
    129

    Array Subscript Out of Range

    I'm sure this one will be easy for many of you, but right now I just don't see why I'm getting a Run-time error '9", Subscript out of range on my assignment statement. Here's the code:

    Please Login or Register  to view this content.
    LastRow = 442 in my case, and it fails on the first assignment statement. I'm just trying to make the 7th column = a concatenation of the 1st 6 columns. Any ideas?

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Array Subscript Out of Range

    Try:

    Please Login or Register  to view this content.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Array Subscript Out of Range

    Change
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    05-13-2010
    Location
    Dallas, TX
    MS-Off Ver
    2019
    Posts
    129

    Re: Array Subscript Out of Range

    Quote Originally Posted by jindon View Post
    Change
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    That worked! Can you explain why yours works and mine wouldn't? I'm pretty new to arrays.

  5. #5
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Array Subscript Out of Range

    Even you dimension the array to a particular size, it will automatically resize when you load the value from the range.
    So you will need to resize the array afterwords.

  6. #6
    Forum Contributor
    Join Date
    05-13-2010
    Location
    Dallas, TX
    MS-Off Ver
    2019
    Posts
    129

    Re: Array Subscript Out of Range

    Quote Originally Posted by jindon View Post
    Even you dimension the array to a particular size, it will automatically resize when you load the value from the range.
    So you will need to resize the array afterwords.
    Makes sense. I never knew that. Thanks.

  7. #7
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: Array Subscript Out of Range

    Deleted. Jindon already provided an answer.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  8. #8
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Array Subscript Out of Range

    You are welcome and thanks for the rep.

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  9. #9
    Forum Contributor
    Join Date
    05-13-2010
    Location
    Dallas, TX
    MS-Off Ver
    2019
    Posts
    129

    Re: Array Subscript Out of Range

    Quote Originally Posted by bakerman2 View Post
    Deleted. Jindon already provided an answer.
    Your tagline, "Avoid using Select, Selection and Activate in your code. Use With ... End With instead." intrigues me. Is there a write-up on this somewhere? I'm always wanting to learn better techniques.

+ 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 - But Array is in different workbook
    By CRIMEDOG in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-21-2015, 02:29 PM
  2. [SOLVED] Subscript out of range - Array empty
    By sperry2565 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-09-2014, 02:19 PM
  3. [SOLVED] Sheets Array - Subscript Out Of Range
    By goss in forum Excel General
    Replies: 2
    Last Post: 11-29-2012, 12:00 PM
  4. [SOLVED] Subscript out of range on Array
    By ZiadzExcel in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-26-2012, 11:35 AM
  5. Subscript out of range error while populating array from range.
    By Aussiexile in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-04-2010, 02:22 AM
  6. [SOLVED] 1D Array Problem (Subscript Out Of Range)
    By John in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-30-2006, 11:37 AM
  7. Subscript out of range - multi array
    By Buffyslay in forum Excel General
    Replies: 6
    Last Post: 02-15-2006, 10:15 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