PDA

View Full Version : Unexpected "Subscription out of range" error



ya_Muntaqim
03-07-2013, 01:47 AM
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..:banghead:

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!

Bob Phillips
03-07-2013, 02:06 AM
It means that you do not have a worksheet called Sheet1 in the active workbook.

ya_Muntaqim
03-07-2013, 02:11 AM
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!

Bob Phillips
03-07-2013, 02:42 AM
VBA uses English for functions, and translates functions, but not sheet names :)