subscript out of range

  • hello
    when I run the code below I receive the error message 9: subscript is out of range.
    I'm trying to work with several workbooks using a macro in the personal.xls, and I'm pretty sure that I must have made a mistake in the way I refer to the workbooks. The problem is I've spent so much time over it, that I don't know what to look for. Can anybody help me?

    the code:



  • Re: subscript out of range

    Hi thomach,
    The code doesn't start the for loop in the second block, the block "create foreign sheets". Everything is ok until there.

    the problem is that when the error appears, i don't even receive the offer of debugging. That's why I think this might be due to the fact that it thinks a workbook isn't open, despite the fact that they are open. I have checked the names, and they are right...

  • Re: subscript out of range

    Since you have the "On Error Goto METHOD_ERROR" statement, you probably cant see exactly where the code is stopping. Comment out that line and any other On Error statements in functions that may call this function.

    Once you do that, the code will enter the debugger mode when it hits the error. Should help you isolate where the problem is.

    Alternatively, you can step through your code in the debugger, but I find that annoying if you have loops.