Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Subscript out of range error

On Mar 9, 9:41 am, Dave Peterson wrote:
Subscript out of range means that there's some sort of collection that doesn't
have element by the name/index you're using.

In this line:

Range(rcd, rcd.End(xlToRight)).Copy _
Destination:=Worksheets(rt).Range("A65536").End(xl Up).Offset(1, 0)

The only thing I see that could cause that error is worksheets(rt).

If rt is a number (say 1234), then worksheets(1234) means the 1234th worksheet
from the left.

You could use this to make sure you're using the name of the sheet--not the
index:

Range(rcd, rcd.End(xlToRight)).Copy _
Destination:=Worksheets(cstr(rt)).Range("A65536"). End(xlUp).Offset(1, 0)

cstr(rt) (I'd use cstr(rt.value) myself) will convert that number to a
string--so it would be like typing:

worksheets("1234").....

And I'd make another change, too. I'd qualify the range to copy:

worksheets("data").Range(rcd, rcd.End(xlToRight)).Copy _
Destination:=Worksheets(cstr(rt.value)).Range("A65 536").End(xlUp).Offset(1, 0)


Thanks Dave, that's perfect!

And thanks to everyone else who has helped .

cheers

Damien


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
Subscript out of range error? gumby[_3_] Excel Programming 7 July 28th 06 07:51 PM
Runtime Error - Subscript out of range despite On Error statement DoctorG Excel Programming 3 July 28th 06 03:56 PM
Subscript out of range error - save copy error bg18461[_16_] Excel Programming 2 June 13th 06 04:53 PM
Subscript out of range error - save copy error bg18461[_15_] Excel Programming 1 June 13th 06 04:36 PM
Type Mismatch error & subscript out of range error Jeff Wright[_2_] Excel Programming 3 May 14th 05 07:14 PM


All times are GMT +1. The time now is 10:58 PM.

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

About Us

"It's about Microsoft Excel"