Run-time error'9' Subscript out of range. How do I sort? Please

G

Guest

I have a monthly accounts system that when i 'create new period' it moves my
closing stocks forward to become new period opening stocks. Its worked for
years but now I get a Box headed Microsoft Virtual Basic and it says Run-time
error '9' and below it says Subscript out of range.
The Debug box, when pressed, runs for ever and the Help box, when pressed,
give me help in what to me is gobbldygook. Is ther a simple answer please.
Window xp. Excel
 
C

Chip Pearson

You get an error 9 when you attempt to access an item that does not exist in
a collection or access an element outside the bounds of an array. For
example,

Debug.Print Worksheets("SheetName").Name

will blow up with an error 9 if "SheetName" doesn't exist. Similarly,

Dim V(1 To 3)
Debug.Print V(4)

will blow up since V has only 3, not 4, elements.

Step through your code by pressing F8 to step from line to line, determine
the line of code that causes the error, and post the code here.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)

"(e-mail address removed)"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top