+ Reply to Thread
Results 1 to 6 of 6

Run Time Error '9' - Subscript Out of Range.

  1. #1
    Registered User
    Join Date
    10-09-2018
    Location
    USA
    MS-Off Ver
    2016
    Posts
    4

    Run Time Error '9' - Subscript Out of Range.

    Hi All,

    I am new to VBA and Excel Programming. I encountered the 'Run Time Error '9' - Subscript Out of Range' error while i tried to load the data. This is existing code. This code was written in Year 2010, I am not sure recent upgrade may causing this error.

    code is
    Please Login or Register  to view this content.
    Thanks for you help.
    Last edited by alansidman; 10-10-2018 at 12:34 AM.

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,274

    Re: Run Time Error '9' - Subscript Out of Range.

    Does your new workbook only have 1 sheet in it perhaps?

    Also, please use code tags when posting code.
    Remember what the dormouse said
    Feed your head

  3. #3
    Forum Contributor
    Join Date
    08-16-2012
    Location
    Sydney
    MS-Off Ver
    Excel 2019
    Posts
    209

    Re: Run Time Error '9' - Subscript Out of Range.

    Hi,

    when you perform
    Please Login or Register  to view this content.
    , check how many sheets it creates? if it only create 1 sheet, then
    Please Login or Register  to view this content.
    will fail, you need at least 3 sheets to perform your code, since you code specifying changing sheet1 , 2 and 3 to different name.

    Also, please use Tag Code

    Thanks
    Lex

  4. #4
    Registered User
    Join Date
    10-09-2018
    Location
    USA
    MS-Off Ver
    2016
    Posts
    4

    Re: Run Time Error '9' - Subscript Out of Range.

    Hi All,

    Thank you for your response. What is mean by code tags.
    Initially it has only one sheet, Now i have added two more sheets and named them accordingly.

    Still it is failing at sheet2.

    I have been executing this code for long time. I never faced this issue in past. But I we migrated to latest MS accesses. Is this causing issue?.

    Thank you

  5. #5
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,944

    Re: Run Time Error '9' - Subscript Out of Range.

    @joyjyothi

    Code Tags Added
    Your post does not comply with Rule 2 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found at http://www.excelforum.com/forum-rule...rum-rules.html



    (I have added them for you today. Please take a few minutes to read all Forum Rules and comply in the future.)
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  6. #6
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,274

    Re: Run Time Error '9' - Subscript Out of Range.

    It’s an Excel setting. If it’s set to only use 1 sheet by default, your code will always fail. You should test how many sheets there are in the new workbook before you use them.

+ 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. Run-time error 9 subscript out of range
    By alazar in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-08-2018, 10:26 AM
  2. Run time error '9': Subscript out of Range
    By mklindquist0815 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-30-2016, 12:35 PM
  3. [SOLVED] Run-time error '9': subscript out of range - error occurs on multiple computers except one
    By BrettE in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-06-2014, 11:19 PM
  4. Run-time error 9: Subscript out of Range
    By boesingen in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-14-2013, 09:41 AM
  5. [SOLVED] Run Time Error 9 - Subscript out of range
    By kushmakarsharma in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-25-2012, 08:02 AM
  6. Run Time Error 9: Subscript Out of Range
    By jason_kelly in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-14-2011, 01:44 PM
  7. Run-time error '9': subscript out of range
    By nicko54 in forum Excel General
    Replies: 6
    Last Post: 02-02-2011, 09:08 PM

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