Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 175
Default Help on error...

For Each turnplot In
Workbooks("AF-Scenario").Worksheets("HexArray").Range("D30:D429" ).Cells

is causing a "Runsub script out of range" error.

AF-Scenario is open but is not the active sheet (the macro is running from
the active sheet and the code inside the loops are drawing shapes and lines
to the active sheet)

The error occurs, the very first time, the For Each... is executed. The
loop statment getting the error is the fourth loop in the macro. The other 3
loops are working fine and all 3 use this type of code:
For Each n In
Workbooks("AF-Scenario.xls").Worksheets("HexArray").Range("D30:D 429").Cells

Why would this kind of loop work 3 times in a row then the 4th time (only
difference is that "n" is now "turnplot") it gets the subscript error...

I am deleting a group of autoshapes (on the active sheet) in a loop just
prior to the 4th loop. But I do the same thing for all the lines just prior
to the 1st loop.

The 1st three loops are looking at the exact same range of cells even...

Any suggestions are appreciated.
--
Regards,
John
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 175
Default Help on error...

Correction:
"Run-time error 9: Sub-script out of range"

is the complete error text...



"John Keith" wrote:

For Each turnplot In
Workbooks("AF-Scenario").Worksheets("HexArray").Range("D30:D429" ).Cells

is causing a "Runsub script out of range" error.

AF-Scenario is open but is not the active sheet (the macro is running from
the active sheet and the code inside the loops are drawing shapes and lines
to the active sheet)

The error occurs, the very first time, the For Each... is executed. The
loop statment getting the error is the fourth loop in the macro. The other 3
loops are working fine and all 3 use this type of code:
For Each n In
Workbooks("AF-Scenario.xls").Worksheets("HexArray").Range("D30:D 429").Cells

Why would this kind of loop work 3 times in a row then the 4th time (only
difference is that "n" is now "turnplot") it gets the subscript error...

I am deleting a group of autoshapes (on the active sheet) in a loop just
prior to the 4th loop. But I do the same thing for all the lines just prior
to the 1st loop.

The 1st three loops are looking at the exact same range of cells even...

Any suggestions are appreciated.
--
Regards,
John

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Help on error...

See the obvious difference

Workbooks("AF-Scenario").Worksheets("HexArray").Range("D30:D429" ).Cells
Workbooks("AF-Scenario.xls").Worksheets("HexArray").Range("D30:D 429").Cells

the one that works has .xls on the end of the workbook name.

--
Regards,
Tom Ogilvy


"John Keith" wrote in message
...
Correction:
"Run-time error 9: Sub-script out of range"

is the complete error text...



"John Keith" wrote:

For Each turnplot In
Workbooks("AF-Scenario").Worksheets("HexArray").Range("D30:D429" ).Cells

is causing a "Runsub script out of range" error.

AF-Scenario is open but is not the active sheet (the macro is running

from
the active sheet and the code inside the loops are drawing shapes and

lines
to the active sheet)

The error occurs, the very first time, the For Each... is executed.

The
loop statment getting the error is the fourth loop in the macro. The

other 3
loops are working fine and all 3 use this type of code:
For Each n In

Workbooks("AF-Scenario.xls").Worksheets("HexArray").Range("D30:D 429").Cells

Why would this kind of loop work 3 times in a row then the 4th time

(only
difference is that "n" is now "turnplot") it gets the subscript error...

I am deleting a group of autoshapes (on the active sheet) in a loop just
prior to the 4th loop. But I do the same thing for all the lines just

prior
to the 1st loop.

The 1st three loops are looking at the exact same range of cells even...

Any suggestions are appreciated.
--
Regards,
John



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 175
Default Help on error...

Sometimes I need to be smacked in the face with it. I'm glad I pasted each
example so you could catch that for me. I thought I had had the code
working before, but i forgot that I had copied the 4th loop and had to add
the workbooks portion of that statement... Thanks Tom

"Tom Ogilvy" wrote:

See the obvious difference

Workbooks("AF-Scenario").Worksheets("HexArray").Range("D30:D429" ).Cells
Workbooks("AF-Scenario.xls").Worksheets("HexArray").Range("D30:D 429").Cells

the one that works has .xls on the end of the workbook name.

--
Regards,
Tom Ogilvy


"John Keith" wrote in message
...
Correction:
"Run-time error 9: Sub-script out of range"

is the complete error text...



"John Keith" wrote:

For Each turnplot In
Workbooks("AF-Scenario").Worksheets("HexArray").Range("D30:D429" ).Cells

is causing a "Runsub script out of range" error.

AF-Scenario is open but is not the active sheet (the macro is running

from
the active sheet and the code inside the loops are drawing shapes and

lines
to the active sheet)

The error occurs, the very first time, the For Each... is executed.

The
loop statment getting the error is the fourth loop in the macro. The

other 3
loops are working fine and all 3 use this type of code:
For Each n In

Workbooks("AF-Scenario.xls").Worksheets("HexArray").Range("D30:D 429").Cells

Why would this kind of loop work 3 times in a row then the 4th time

(only
difference is that "n" is now "turnplot") it gets the subscript error...

I am deleting a group of autoshapes (on the active sheet) in a loop just
prior to the 4th loop. But I do the same thing for all the lines just

prior
to the 1st loop.

The 1st three loops are looking at the exact same range of cells even...

Any suggestions are appreciated.
--
Regards,
John




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error: "Excel encountered an error and had to remove some formatti Carl Excel Discussion (Misc queries) 0 September 18th 06 06:39 PM
Counting instances of found text (Excel error? Or user error?) S Davis Excel Worksheet Functions 5 September 12th 06 04:52 PM
I have Error 1919 Error Configuring ODBC dataSource Database Texanna1 Excel Discussion (Misc queries) 1 September 12th 06 06:35 AM
Automation Error, Unknown Error. Error value - 440 Neo[_2_] Excel Programming 0 May 29th 04 05:26 AM


All times are GMT +1. The time now is 02:30 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"