Consulting

Results 1 to 4 of 4

Thread: Unexpected "Subscription out of range" error

  1. #1

    Unexpected "Subscription out of range" error

    Hi all,
    I am new here and I am a newbie with VBA. These are just my first steps.

    I have met this sort of problem while trying to go through VBA for Dummies lessons..

    Sub ShowValue()
    Contents = Worksheets(“Sheet1”).Range(“A1”).Value
    MsgBox Contents
    End Sub


    This should be sooo easy according to the book, but I can't move on with the material because of the error 9 "Subscription ouf of range".

    What's the problem. Pls help me, or I will go mad...

    I am using excel 2007 btw.

    thanks in advance for your answers!

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,247
    Location
    It means that you do not have a worksheet called Sheet1 in the active workbook.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    This one is sorted out!))

    The problem was that in Polish excel stands Arkusz1 instead of Sheet1. I was thinking that vba can interprete the language diffrences automatically. How naive was I

    Thanks mate!

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,247
    Location
    VBA uses English for functions, and translates functions, but not sheet names
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •