Thread
:
Subscript out of range error
View Single Post
#
2
Posted to microsoft.public.excel.programming
Don Guillett
external usenet poster
Posts: 10,124
Subscript out of range error
I'm confused about your syntax but the basic idea is that you tried to paste
without selecting. So, just shortcut it by this one liner. BTW you can
usually break up a line with a space and underscore
sourcerange.copy destinationrange
or
sourcerange.copy _
destinationrange
--
Don Guillett
SalesAid Software
"Damien McBain" wrote in message
...
This code returns a "Subscript out of range error at the marked line (it's
1 line in the code but wrapped in this post). The "copy" method works
because the correct range is copied but the error occurs on the line with
the paste method:
=======================
Sub ProcessData()
For Each rt In Worksheets("Routes").Range("A2",
Worksheets("Routes").Range("A2").End(xlDown))
With Worksheets.Add
.Name = rt
End With
For Each rcd In Worksheets("Data").Range("A2",
Worksheets("Data").Range("A2").End(xlDown))
If rcd.Value = rt.Value Then
Range(rcd, rcd.End(xlToRight)).Copy
Worksheets(rt).Worksheets(rt).Range(Range("A1").En d(xlDown).Offset(1, 0),
Range("A1").End(xlDown).Offset(1, 9)).Paste '<<<---- problem line
Else
End If
Next rcd
Next rt
End Sub
===========================
I have also tried pasting to a 1 cell range
[Worksheets(rt).Range("A1").End(xlDown).Offset(1, 0)] which also generates
an error.
The data which is copied is A2:I2 (1 row x 9 columns)
Any ideas? So close... :/
cheers
Damien
Reply With Quote
Don Guillett
View Public Profile
Find all posts by Don Guillett