P
packat
I have searched far and wide and found several questions on subscript
out of range issue, but none of these questions seem to be similar to
mine. I am very new to VBA, so my vocabulary may not be standard...
I received an old spreadsheet application from a co-worker. When I
ran the macro that activate a VBA code, it ran fine and produce
correct results.
The problem occurs when I made changes to some of the data entries
(all floats) to tweak the model, I got the run-time error 9. The
changes are within the original range and of the same data type.
Since nothing else were changed (e.g. tab name, etc) so I assumed the
problem was not caused by typo as it seems to be the common source of
this error.
When I debug the code, I found
- The error occurred at line
Set w1 = ActiveWorkbook.Worksheets(Trim$
(run_.terminal_model_name))
where run_ is an object defined early on in the code.
- The value of "run_.terminal_model_name" was different from the
correct value when the model ran successfully. This suggests VBA was
confused and get the worksheet all mixed up.
Also, even when I undo the changes back to original, the code still
produce the same error.
I am refraining from posting he entire code since it is a bit large
and hard to read. Besides, I might have to discuss posting the code
to public forum with my co-worker who crated this code.
I am really stumped and would very much appreciate any idea of what
causes this problem and how to solve it.
pax
out of range issue, but none of these questions seem to be similar to
mine. I am very new to VBA, so my vocabulary may not be standard...
I received an old spreadsheet application from a co-worker. When I
ran the macro that activate a VBA code, it ran fine and produce
correct results.
The problem occurs when I made changes to some of the data entries
(all floats) to tweak the model, I got the run-time error 9. The
changes are within the original range and of the same data type.
Since nothing else were changed (e.g. tab name, etc) so I assumed the
problem was not caused by typo as it seems to be the common source of
this error.
When I debug the code, I found
- The error occurred at line
Set w1 = ActiveWorkbook.Worksheets(Trim$
(run_.terminal_model_name))
where run_ is an object defined early on in the code.
- The value of "run_.terminal_model_name" was different from the
correct value when the model ran successfully. This suggests VBA was
confused and get the worksheet all mixed up.
Also, even when I undo the changes back to original, the code still
produce the same error.
I am refraining from posting he entire code since it is a bit large
and hard to read. Besides, I might have to discuss posting the code
to public forum with my co-worker who crated this code.
I am really stumped and would very much appreciate any idea of what
causes this problem and how to solve it.
pax