+ Reply to Thread
Results 1 to 5 of 5

Run Time Error 9 Subscript Out of Range - Happening to only 1 user?

Hybrid View

  1. #1
    Registered User
    Join Date
    03-10-2014
    Location
    Sheffield, UK
    MS-Off Ver
    Excel 2013
    Posts
    20

    Run Time Error 9 Subscript Out of Range - Happening to only 1 user?

    Hi Guys,

    I am stumped with this error, which seems to be happening to only one of my users...

    I have a long code, which starts with declarations including a sheet name. The sheet name is the current month in the form MMM-YY, e.g. 'Feb-15'. This is to select the worksheet in another workbook with that sheet name later on in the code.

    Option Explicit
    Sub SaveButton_Click()
    
    Application.ScreenUpdating = False
    Application.Calculate
    
    Sheets("Copy").Range("CG1").Value = "some text goes here"
    
    PleaseWait.Show vbModeless
    DoEvents
    
        Sheets("Copy").Select
        Sheets("Copy").Range("D2:D9").Value = Sheets("ONE").Box1.Value
        Sheets("Copy").Range("E2:E9").Value = Sheets("TWO").Box2.Value
        Sheets("Copy").Range("A11:U18").Value = Sheets("Copy").Range("A2:U9").Value
    
        Dim FName As String
        Dim IsClosed  As Boolean
        Dim strSheet As String
        Dim strTeam As String
    
    strSheet = Workbooks("Book1").Sheets("Copy").Range("D20")
    strTeam = Workbooks("Book1").Sheets("actions").Range("U54")
    FName = "//the file path goes here/" & strTeam & " - Log.xlsm"
    
    'More Code Goes Here......
    
    End Sub
    The code that is highlighted when the user gets the run time error is the "strSheet =" line.

    "Book1" is the ActiveWorkbook where the code runs. "D20" has the formula "=TEXT(TODAY(),"MMM-YY")" and currently shows Feb-15 which is a valid sheet within the workbook that will open later (FName), (although when the code crashes, it is only setting the string name).

    However, this code all runs fine for me, it's just happening to one user. Also, it was working all throughout January for him (when D20 showed Jan-15), only now in February it has stopped working, so maybe it is the Feb-15 bit??

    Does anyone have any ideas on why it would crash on that line??

    I was thinking maybe it is the user's own Excel settings?

    Thanks,
    ExcelNat

  2. #2
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Run Time Error 9 Subscript Out of Range - Happening to only 1 user?

    Any chance your user has a different Book1 open? That error 9 usually suggests the sheet or book doesn't exist? Doesn't make much sense since there are other lines that reference sheets("copy") but don't know where else to start.
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

  3. #3
    Registered User
    Join Date
    03-10-2014
    Location
    Sheffield, UK
    MS-Off Ver
    Excel 2013
    Posts
    20

    Re: Run Time Error 9 Subscript Out of Range - Happening to only 1 user?

    No not really, I've already checked that he's using the correct version of Book1 too. Book1 is saved on a network drive as ReadOnly and all users (about 24 users) access the same Book1 which they enter data into and it then goes and saves onto the relevant spreadsheet (FName). And as I said, all other users are doing fine. When I replicated what the problem user had just done, I got no errors at all.
    I think this is probably more of a computer issue. Maybe a reboot will do the trick?!

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: Run Time Error 9 Subscript Out of Range - Happening to only 1 user?

    What happens if you add the appropriate file extension to Book1, eg Book1.xlsm, or change Workbooks("Book1") to ActiveWorkbook?
    If posting code please use code tags, see here.

  5. #5
    Registered User
    Join Date
    03-10-2014
    Location
    Sheffield, UK
    MS-Off Ver
    Excel 2013
    Posts
    20

    Re: Run Time Error 9 Subscript Out of Range - Happening to only 1 user?

    Changed it to ActiveWorkbook instead and that seems to have worked!!!

    Still baffled as to why it even did it in the first place!

    Thanks for your help :-D

+ 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 chergian in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-06-2014, 02:40 AM
  2. [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
  3. [SOLVED] Run-time Error '9': Subscript out of Range
    By Veena Anoohya in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-19-2014, 05:06 AM
  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. VB Run-time error '9'; Subscript out of range
    By lisabethvw in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-29-2009, 03:49 AM

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