+ Reply to Thread
Results 1 to 11 of 11

VBA run-time Error 9: subscript out of range

  1. #1
    Registered User
    Join Date
    11-12-2019
    Location
    Scotland
    MS-Off Ver
    MS Office Pro Plus 365
    Posts
    6

    VBA run-time Error 9: subscript out of range

    Hi there. I'm currently coming up against a stumbling block with the VBA run-time Error 9 appearing with the following code:

    Essentially what I need it to do is open up all worksheets, clear the content of the table, change cells white and colour the 1st column red, except for the worksheet named "Overall".

    Debug suggests this line is at fault..."Set tbl = ws.ListObjects(1)"?

    Please Login or Register  to view this content.
    Many thanks for your help.

  2. #2
    Valued Forum Contributor
    Join Date
    06-27-2010
    Location
    sYRIA
    MS-Off Ver
    Excel 2013
    Posts
    669

    Re: VBA run-time Error 9: subscript out of range

    Well
    As I can see this error pop up if the sheet has no table in
    so ether make sure tables as exist in all sheets Or ...

  3. #3
    Registered User
    Join Date
    11-12-2019
    Location
    Scotland
    MS-Off Ver
    MS Office Pro Plus 365
    Posts
    6

    Re: VBA run-time Error 9: subscript out of range

    Thanks mohadin. All sheets have at least 1 table except from "Overall" which I'm asking it to ignore.

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

    Re: VBA run-time Error 9: subscript out of range

    Please Login or Register  to view this content.
    Is the sheet name correct?
    Doesn't actual sheet name have extra space or something?

  5. #5
    Registered User
    Join Date
    11-12-2019
    Location
    Scotland
    MS-Off Ver
    MS Office Pro Plus 365
    Posts
    6

    Re: VBA run-time Error 9: subscript out of range

    Hi Jindon. Sheet name is "Overall" without extra spaces or characters.

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

    Re: VBA run-time Error 9: subscript out of range

    Then it should work...

    When you run the code and encounter the error.
    Go to debug mode and just hover the cursor over the ws.Name (not click), so you can actually read the sheet name that raises the error.

  7. #7
    Registered User
    Join Date
    11-12-2019
    Location
    Scotland
    MS-Off Ver
    MS Office Pro Plus 365
    Posts
    6

    Re: VBA run-time Error 9: subscript out of range

    Jindon thank you. Never knew you could hover the cursor over so read the sheet raising the error.

    It appears that there are hidden sheets, "Blank" and "Control". Now need to figure out how to ignore all 3.

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

    Re: VBA run-time Error 9: subscript out of range

    Then perhaps...
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    11-12-2019
    Location
    Scotland
    MS-Off Ver
    MS Office Pro Plus 365
    Posts
    6

    Re: VBA run-time Error 9: subscript out of range

    Fantastic Jindon - hugely appreciated.

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

    Re: VBA run-time Error 9: 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.

  11. #11
    Registered User
    Join Date
    11-12-2019
    Location
    Scotland
    MS-Off Ver
    MS Office Pro Plus 365
    Posts
    6

    Re: VBA run-time Error 9: subscript out of range

    Most certainly does. Thread marked as Solved

+ 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] Run Time Error 9: Subscript out of Range
    By xyza12 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-30-2015, 03:56 AM
  2. [SOLVED] Run-time error '9': Subscript out of range
    By chergian in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-06-2014, 02:40 AM
  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. [SOLVED] Run-time error '9': Subscript out of range
    By billj in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-03-2013, 11:30 PM
  5. Run-time Error '9': Subscript out of Range
    By bcn1988 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-11-2012, 03:01 PM
  6. Run time error 9 Subscript out of range
    By vijanand1279 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-28-2012, 03:30 PM
  7. run-time error '9': Subscript out of range
    By AccessHelp in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-30-2005, 01:05 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