Originally Posted by
Norie
Are you saying that if you use something like this you get a Subscript out of range error?
Also, using something like that triggers some other code?
Yes. Using that exact code returns Error 9 when the line is executed. Then the macro continues processing down to the saving of the third new workbook, even when F8ing in debug mode.
I've seen a suggestion that in cases like this it's worth CTRL-F8ing for each line. Doing that, the Error 9 occurs when processing this line:
Using the wbFile definition I was able to replace that line by doing this:
This fixes the Error 9, but Error 1004 appears again in the next section of code:
CTRL-F8ing each line again seems to track it to a reference to Workbooks(SRateFile). It would make sense to get the same error again when I'm doing the same thing. I'll try replacing all references to other workbooks with a defined Workbook variable and see what happens.
Edit: Error 1004 returned when attempting to execute the Do Until loop. The initial section is now fixed, though.
(I'd still love to know why the debugger is processing multiple lines of code in stepwise mode.)
Bookmarks