I dont know whether you have come across this..

I wrote a vba code sometime ago and i was happy with the way it worked. But i was really surprised to find that the same code doesnt work now. Well, you might be familiar with this "subscript out of range", but what i dont understand is, the same code worked like 4 weeks back on the same pc without any change in the windows/office version.
One of the solution that i was suggested was, to put all my code under modules, well it did work for somebody which i found over the net, but actually, i do not want to that. Anyone ever come across this problem before and solved it, or tried to..please reply to this topic as it would be helpful :)
Thank you very much.



Answer this question

I dont know whether you have come across this..

  • Julian Jelfs

    Hi Ram,

    That sometime happens to me too. Sometimes everything runs fine for about 6 months and then some errors pop up. Sometimes it's machine related, sometimes it's user related, sometimes it was just a mistake.

    The subscript out of range error is usually related to something being removed from the data the code works on, or something has been changed.

    For example your code expects 100 lines of data and there are only 99, or the code expects a worksheet and it has been deleted or renamed. Something has been changed that your code doesn't expect.

    This could have been something the user has done, something you have done or some conditions have occurred that you didn't expect in code. Placing all your code in modules wouldn't necessary solve the problem. Have a look at the line of code that has the error and take it from there.



  • Secor_BobF

    Thanks Derek, I got the code working (well some if it) if i change the syntax for some of the code i have used. I dont know why it did this because, i havnt changed the code at all, so if its expecting 100 lines, there are still 100 lines. But anyway, its just "weird". Thanks for your reply btw.

  • I dont know whether you have come across this..