+ Reply to Thread
Results 1 to 5 of 5

Accessing worksheets: error 9: subscript out of range

  1. #1
    Registered User
    Join Date
    05-28-2014
    Posts
    6

    Accessing worksheets: error 9: subscript out of range

    Hi everyone,
    This is my first VBA project so any help is appreciated! The following code is the beginning of a function I am writing to save a spreadsheet to file. When I include the fourth line (saveFolder = ...), I get error '9': subscript out of range. I am trying to access the worksheet because it has the folder location I plan to save the file to. How can I fix this? Thanks!!


    Private Sub btnExport_Click()
    Workbooks("Timesheet Userform.xlsm").Activate
    Worksheets("Timesheet").Activate
    saveFolder = Worksheets("Timesheets").Cells(2, 2)
    ActiveSheet.Copy
    ...
    ...

  2. #2
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: Accessing worksheets: error 9: subscript out of range

    Is there a worksheet called Timesheets not Timesheet?
    Hope this helps

    Sometimes its best to start at the beginning and learn VBA & Excel.

    Please dont ask me to do your work for you, I learnt from Reading books, Recording, F1 and Google and like having all of this knowledge in my head for the next time i wish to do it, or wish to tweak it.
    Available for remote consultancy work PM me

  3. #3
    Valued Forum Contributor ranman256's Avatar
    Join Date
    07-29-2012
    Location
    Kentucky
    MS-Off Ver
    Excel 2003
    Posts
    1,177

    Re: Accessing worksheets: error 9: subscript out of range

    It might be trying to get something OTHER than the value in the cell, so make sure of it...
    saveFolder = Worksheets("Timesheets").Cells(2, 2).value

    it could also be the subscript of the worksheets is out of range. (no sheet called "Timesheets").

  4. #4
    Registered User
    Join Date
    05-28-2014
    Posts
    6

    Re: Accessing worksheets: error 9: subscript out of range

    Oh thanks , that was silly.
    So I'm back to my old problem. The error is gone but nothing gets saved to the variable even though the cell has data

  5. #5
    Registered User
    Join Date
    05-28-2014
    Posts
    6

    Re: Accessing worksheets: error 9: subscript out of range

    Okay, problem solved now. Thanks everyone

+ 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 - 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
  2. Subscript out of Range Error with using Worksheets.Select on an existing Worksheet
    By SDaniela in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-21-2014, 05:23 AM
  3. Defining Array - Runtime error 9, Subscript out of range error
    By MaartenW in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-03-2012, 07:32 AM
  4. Type Mismatch error & subscript out of range error
    By Jeff Wright in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-14-2005, 03:06 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