+ Reply to Thread
Results 1 to 6 of 6

"Runtime error '9': subscript out of range" when running UserForm

  1. #1
    Registered User
    Join Date
    04-23-2019
    Location
    Pittsburgh, PA
    MS-Off Ver
    MS Office 365
    Posts
    7

    Post "Runtime error '9': subscript out of range" when running UserForm

    Afternoon!

    I'm working on a simple project 'database' of sorts for my company.
    I've created a UserForm to make the data entry easier, using a macro set I found online.

    When adjusting the naming conventions to meet my needs, I continually come up against the "Runtime error '9': Subscript out of range" bug. (The code below shows my edits.)

    I have checked, and re-checked the sheet names, and cannot find the error.

    The debugger is highlighting the piece of code in red below (I can't post links or pictures yet, so this will have to do )

    Private Sub cmdAdd_Click()
    'Copy input values to sheet.
    Dim lRow As Long
    Dim wb As Workbook
    Dim ws As Worksheets

    Set wb = ActiveWorkbook
    Set ws = wb.Sheets("Projects")


    All help is much appreciated!

    Please Login or Register  to view this content.
    Attached Images Attached Images
    Last edited by Niccii; 04-23-2019 at 03:55 PM.

  2. #2
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,077

    Re: "Runtime error '9': subscript out of range" when running UserForm

    You don't have a sheet called Projects in the workbook.
    Projects is the codename & should be used like
    Please Login or Register  to view this content.
    or just
    Please Login or Register  to view this content.

  3. #3
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,475

    Re: "Runtime error '9': subscript out of range" when running UserForm

    You say the debugger highlights the text in red, but the debugger image shows it is highlighting the line below that.

    That should indicate there is no worksheet named "Projects" in the ActiveWorkbook and if there is, the sheet name may not be exactly like it shows in the code. There may be a space or caps are different.

  4. #4
    Registered User
    Join Date
    04-23-2019
    Location
    Pittsburgh, PA
    MS-Off Ver
    MS Office 365
    Posts
    7

    Re: "Runtime error '9': subscript out of range" when running UserForm

    Quote Originally Posted by Fluff13 View Post
    You don't have a sheet called Projects in the workbook.
    Projects is the codename & should be used like
    Please Login or Register  to view this content.
    OF COURSE it was just that simple!!! I must have been messing with the wrong Name values in the properties... Thank you so much, that worked like a charm!

  5. #5
    Registered User
    Join Date
    04-23-2019
    Location
    Pittsburgh, PA
    MS-Off Ver
    MS Office 365
    Posts
    7

    Re: "Runtime error '9': subscript out of range" when running UserForm

    Quote Originally Posted by davesexcel View Post
    You say the debugger highlights the text in red, but the debugger image shows it is highlighting the line below that.

    That should indicate there is no worksheet named "Projects" in the ActiveWorkbook and if there is, the sheet name may not be exactly like it shows in the code. There may be a space or caps are different.
    Thanks for catching that, my mistake. I'm glad the forum decided to let me keep my highlighted image in the post after all!

  6. #6
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,077

    Re: "Runtime error '9': subscript out of range" when running UserForm

    You're welcome & thanks for the feedback

+ 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. Runtime error 9 "subscript out of range"
    By aliy2k4u in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-13-2019, 08:37 PM
  2. Urgent help needed - "Runtime error 9: subscript out of range"
    By lostman in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-29-2018, 12:04 PM
  3. Runtime Error 9 "Subscript Out of Range" Assistance
    By hg_macro_support in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-18-2016, 05:28 AM
  4. Runtime error 9 "subscript out of range"
    By PUZEYQUIN in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-29-2014, 11:38 AM
  5. Runtime error 9 "subscript out of range"
    By Frustratedemployee in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 08-30-2013, 06:48 PM
  6. Runtime error 9 "subscript out of range"
    By eLakmal in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-08-2013, 10:09 PM
  7. [SOLVED] Runtime error 9 "subscript out of range"
    By MyCousinVinnie in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-08-2012, 11:28 PM

Tags for this Thread

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