ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Run-time error 9 - Subscript out of range (again) (https://www.excelbanter.com/excel-programming/435162-run-time-error-9-subscript-out-range-again.html)

packat[_3_]

Run-time error 9 - Subscript out of range (again)
 
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

joel

Run-time error 9 - Subscript out of range (again)
 
the dollar sign and under_score may indicate that this code was meant to be
used with some assembly language code that isn't expecting the change to a
float variable. You may be cuasing a problem with passing the variable in
the stack to the assembly language routine (or possibly another language
like C language).

I would need to see more of the code, but I suspect the "RUN Structure TYPE"
is being used to pass the data to another program that isn't expecting the
Float type variable. the number of memory locations for a floating point
variable is different from a single or double type varaiable.

"packat" wrote:

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
.


packat[_3_]

Run-time error 9 - Subscript out of range (again)
 
On Oct 20, 4:37*am, Joel wrote:
the dollar sign and under_score may indicate that this code was meant to be
used with some assembly language code that isn't expecting the change to a
float variable. *You may be cuasing a problem with passing the variable in
the stack to the assembly language routine *(or possibly another language
like C language).

I would need to see more of the code, but I suspect the "RUN Structure TYPE"
is being used to pass the data to another program that isn't expecting the
Float type variable. *the number of memory locations for a floating point
variable is different from a single or double type varaiable.

"packat" wrote:
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
.


Thanks Joel. Your response makes the most sense since I have been
asking this question around in various user group and help board! I
will look further into this.

pax


All times are GMT +1. The time now is 10:40 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com