+ Reply to Thread
Results 1 to 8 of 8

trying to understand why a code is not working "error 9 subscript out off range"

  1. #1
    Registered User
    Join Date
    02-27-2013
    Location
    london
    MS-Off Ver
    Excel 2003
    Posts
    38

    trying to understand why a code is not working "error 9 subscript out off range"

    ok with help from this forum i created this code to insert a date in one sheet
    Please Login or Register  to view this content.
    this works fine if I put on a new workbook but it produces an error on the workbook where i'm trying to implement.

    having said that i found a workable solution as follows
    Please Login or Register  to view this content.
    but i'm quite frustrated that i don't understand why the first code is not working
    i would appreciate if someone have a look on my workbook and could check where the problem lies.

    the error which give me is "error 9 subscript out off range"
    all the code is in module 6 and is to insert a date on sheet(Ex11.5) cell b3.

  2. #2
    Valued Forum Contributor tehneXus's Avatar
    Join Date
    04-12-2013
    Location
    Hamburg, Germany
    MS-Off Ver
    Work: MS-Office 2010 32bit @ Win8 32bit / Home: MS-Office 2016 32bit @ Win10 64bit
    Posts
    944

    Re: trying to understand why a code is not working "error 9 subscript out off range"

    There is no "sheet2" in your workbook, adapt the following line to the worksheet you want to write to:
    Please Login or Register  to view this content.
    e.g.

    Please Login or Register  to view this content.
    Please use [CODE]-TAGS
    When your problem is solved mark the thread SOLVED
    If an answer has helped you please click to give reputation
    Read the FORUM RULES

  3. #3
    Registered User
    Join Date
    02-27-2013
    Location
    london
    MS-Off Ver
    Excel 2003
    Posts
    38

    Re: trying to understand why a code is not working "error 9 subscript out off range"

    Quote Originally Posted by tehneXus View Post
    There is no "sheet2" in your workbook, adapt the following line to the worksheet you want to write to:
    Please Login or Register  to view this content.
    e.g.

    Please Login or Register  to view this content.
    sheet2 is represent sheet "EX11.5" i have tried what your solution but no luck!

  4. #4
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: trying to understand why a code is not working "error 9 subscript out off range"

    Please Login or Register  to view this content.
    runs fine for me note the space before the worksheet name
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  5. #5
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: trying to understand why a code is not working "error 9 subscript out off range"

    "subscript out off range" usually means the worksheet you are referencing does not exist. In the attached there is not sheet called ("sheet2").

  6. #6
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: trying to understand why a code is not working "error 9 subscript out off range"

    Hi, cdafonseca,

    Sheet2 is the codename of the worksheet " EX11.5" and could be used like
    Please Login or Register  to view this content.
    You will find it hard to refer to a sheet from a different workbook by using itīs codename.

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  7. #7
    Registered User
    Join Date
    02-27-2013
    Location
    london
    MS-Off Ver
    Excel 2003
    Posts
    38

    Re: trying to understand why a code is not working "error 9 subscript out off range"

    thanks all for the help the coin has dropped I'm off the dark.

    the solution was the bloody space I had it like this ("Ex11.5") and should be like this (" Ex11.5")

    Am i correct to say that the sheet as been named with a blank space before the name?

  8. #8
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: trying to understand why a code is not working "error 9 subscript out off range"

    yes the worksheet has a space in its name

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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